diff --git a/modules/ContactForm/Providers/ContactFormServiceProvider.php b/modules/ContactForm/Providers/ContactFormServiceProvider.php index 6bb4e7c4..d6c77bc0 100644 --- a/modules/ContactForm/Providers/ContactFormServiceProvider.php +++ b/modules/ContactForm/Providers/ContactFormServiceProvider.php @@ -1,12 +1,9 @@ app->make('registerWidget'); $registrator->register(Address::class, null, ContactForm::getModuleId()); + $registrator->register(Form::class, null, ContactForm::getModuleId()); } } diff --git a/modules/ContactForm/Resources/lang/en/admin/widgets.php b/modules/ContactForm/Resources/lang/en/admin/widgets.php index 3e09aa89..3d387a0d 100644 --- a/modules/ContactForm/Resources/lang/en/admin/widgets.php +++ b/modules/ContactForm/Resources/lang/en/admin/widgets.php @@ -9,7 +9,7 @@ return [ 'form' => [ 'name' => 'Contact form', 'description' => 'Display small contact form anywhere on website.', - 'new' => 'New contact block widget' + 'new' => 'New contact form widget' ], 'noContactForms' => 'You have not created any contact form. Try to create one before creating this widget.', 'selectContactForm' => 'Select contact form' diff --git a/modules/ContactForm/Resources/views/admin/widgets/form/edit.blade.php b/modules/ContactForm/Resources/views/admin/widgets/form/edit.blade.php new file mode 100644 index 00000000..b3b0b98c --- /dev/null +++ b/modules/ContactForm/Resources/views/admin/widgets/form/edit.blade.php @@ -0,0 +1,19 @@ +@extends('admin.layoutWithNavigation') + +@section('pageHeading', @trans('contactform::admin/widgets.address.edit')) +@section('pageDescription', $widget->description) + +@section('content') + + @if(!count($forms)) +
@lang('contactform::admin/widgets.noContactForms')
+ @else +
+ @include('contactform::admin.widgets.form.form', ['action' => route('widgets.postEdit', ['id' => $widget->id])]) +
+
+ @widgetPreview($widget) +
+ @endif +@endsection + diff --git a/modules/ContactForm/Resources/views/admin/widgets/form/form.blade.php b/modules/ContactForm/Resources/views/admin/widgets/form/form.blade.php new file mode 100644 index 00000000..19dfcd3e --- /dev/null +++ b/modules/ContactForm/Resources/views/admin/widgets/form/form.blade.php @@ -0,0 +1,17 @@ +
+ @include('admin.widgets.snippets.commonForm') + + + + + + +
\ No newline at end of file diff --git a/modules/ContactForm/Resources/views/admin/widgets/form/new.blade.php b/modules/ContactForm/Resources/views/admin/widgets/form/new.blade.php new file mode 100644 index 00000000..fc3ff7cb --- /dev/null +++ b/modules/ContactForm/Resources/views/admin/widgets/form/new.blade.php @@ -0,0 +1,14 @@ +@extends('admin.layoutWithNavigation') + +@section('pageHeading', @trans('contactform::admin/widgets.form.new')) +@section('pageDescription', @trans($type->description)) + +@section('content') + + @if(!count($forms)) +
@lang('contactform::admin/widgets.noContactForms')
+ @else + @include('contactform::admin.widgets.form.form', ['action' => route('widgets.postNew', ['type' => $type])]) + @endif +@endsection + diff --git a/modules/ContactForm/Widgets/Address/Presenter.php b/modules/ContactForm/Widgets/Address/Presenter.php index 1901cfff..144f4df7 100644 --- a/modules/ContactForm/Widgets/Address/Presenter.php +++ b/modules/ContactForm/Widgets/Address/Presenter.php @@ -26,9 +26,9 @@ class Presenter implements WidgetRenderer $formData = json_decode($form->module_settings); - $code = '
containerId) { - $code .= ' id="' . e($widget->containerId); + $code = '
container_id) { + $code .= ' id="' . e($widget->container_id).'"'; } $code .= '>'; $code .= "

".e($formData->companyName).'

'; diff --git a/modules/ContactForm/Widgets/Form/Form.php b/modules/ContactForm/Widgets/Form/Form.php new file mode 100644 index 00000000..b6a4e7d7 --- /dev/null +++ b/modules/ContactForm/Widgets/Form/Form.php @@ -0,0 +1,52 @@ +settings = json_encode(['contactFormId' => $data->contactFormId,]); + + return $widget; + } +} \ No newline at end of file diff --git a/modules/ContactForm/Widgets/Form/Presenter.php b/modules/ContactForm/Widgets/Form/Presenter.php new file mode 100644 index 00000000..29435ec7 --- /dev/null +++ b/modules/ContactForm/Widgets/Form/Presenter.php @@ -0,0 +1,75 @@ +settings->contactFormId); + + if (!$form) { + return null; + } + + $form->module_settings = json_decode($form->module_settings); + + return view(self::$template, ['widget' => $widget, 'form' => $form]); + } + + /** + * Display form for creating new instance of widget + * + * @param WidgetType $type + * + * @return mixed + */ + public static function renderAddForm(WidgetType $type) + { + $contactForms = Content::where('module_handler', config('contactform.handler')) + ->get(); + + return view('contactform::admin.widgets.form.new', [ + 'type' => $type, + 'widget' => new Widget(), + 'forms' => $contactForms + ]); + } + + /** + * Display form for editing already existing widget + * + * @param Widget $widget + * + * @return mixed + */ + public static function renderEditForm(Widget $widget) + { + $contactForms = Content::where('module_handler', config('contactform.handler')) + ->get(); + return view('contactform::admin.widgets.address.edit', [ + 'widget' => $widget, + 'forms' => $contactForms + ]); + } +} \ No newline at end of file