use Cubist\Backpack\Magic\Fields\FormSection;
use Cubist\Backpack\Magic\Fields\Number;
use Cubist\Backpack\Magic\Fields\Text;
-use Cubist\Backpack\Magic\SubForm;
+use Cubist\Backpack\Magic\Form;
-class Base extends SubForm
+class Base extends Form
{
const WEB_INFOS = 1;
const PRODUCT = 1;
public static function types()
{
return [
- ['type' => self::WEB_INFOS, 'label' => __('Lien web « plus d\'infos »'), 'color' => '#ff0000', 'class' => WebInfos::class, 'class' => Web::class],
- ['type' => self::WEB, 'label' => __('Lien web'), 'color' => '#3399cc', 'class' => Web::class, 'class' => Web::class],
- ['type' => self::EMAIL, 'label' => __('Adresse e-mail'), 'color' => '#6c6360', 'class' => Web::class],
- ['type' => self::VIDEO, 'label' => __('Vidéo'), 'color' => '#33ff00', 'class' => Web::class],
+ ['type' => self::WEB_INFOS, 'label' => __('Lien web « plus d\'infos »'), 'color' => '#ff0000', 'class' => WebInfos::class],
+ ['type' => self::WEB, 'label' => __('Lien web'), 'color' => '#3399cc', 'class' => Web::class],
+ ['type' => self::EMAIL, 'label' => __('Adresse e-mail'), 'color' => '#6c6360', 'class' => Email::class],
+ ['type' => self::VIDEO, 'label' => __('Vidéo'), 'color' => '#33ff00', 'class' => Video::class],
['type' => self::INTERNAL, 'label' => __('Lien vers une page'), 'color' => '#c7b405', 'class' => Web::class],
['type' => self::MULTIMEDIA, 'label' => __('Multimédia'), 'color' => '#ff00ff', 'class' => Web::class],
['type' => self::CUSTOM, 'label' => __('Lien personnalisé'), 'color' => '#14511a', 'class' => Web::class],
{
$this->addField('header_settings', FormSection::class, __('Autres paramètres'));
}
+
+ public function getType()
+ {
+ return $this->getValue('type');
+ }
+
+ /**
+ * @return string
+ */
+
+ public function render(callable $callback = null)
+ {
+ return view('fluidbook_publication.link_editor_form', ['form' => $this, 'crud' => $this->crud])->render($callback);
+ }
}
</aside>
</div>
<div id="linkeditor-preload"></div>
+ <div id="linkeditor-form-templates">
+ @foreach(\App\SubForms\Link\Base::types() as $f)
+ @if(isset($f['disabled']) && $f['disabled'])
+ @continue;
+ @endif
+ @php
+ $instance=new $f['class']();
+ $instance->setValue('type',$f['type']);
+ echo $instance->render();
+ @endphp
+ @endforeach
+ </div>
@endsection
@push('after_scripts')
@push('after_styles')
<style>
@foreach(\App\SubForms\Link\Base::types() as $type)
- .link[fb-type="{{$type['type']}}"] {
+ .link[fb-type="{{$type['type']}}"] {
color: {{$type['color']}};
background-color: {{\Cubist\Util\Graphics\Color::colorToCSS($type['color'],0.25)}};
}
+ .linkeditor-linktype[data-type="{{$type['type']}}"]::before{
+ background-color: {{$type['color']}};
+ }
@endforeach
</style>
<link rel="stylesheet"
--- /dev/null
+@php
+ start_measure('Render form '.$form->getTitle());
+ $action='create';
+ $fields=$crud->fields();
+@endphp
+
+@if($form->getTitle())
+ <h2>{{$form->getTitle()}}</h2>
+@endif
+<form id="linkeditor-form-template-{{$form->getType()}}" action="{{$form->getAction()}}"
+ enctype="{{$form->getEnctype()}}" method="{{$form->getSafeMethod()}}">
+ <input type="hidden" name="_method" value="{{$form->getMethod()}}">
+ <input type="hidden" name="_referrer" value="{{request()->getRequestUri()}}">
+ @if($form->isCsrf())
+ @csrf
+ @endif
+ @include('crud::form_content')
+</form>
+@php
+ stop_measure('Render form '.$form->getTitle());
+@endphp