Skip to content

Commit

Permalink
Updated contact module so it works with new json editor; updated read…
Browse files Browse the repository at this point in the history
…me; cleanup code
  • Loading branch information
eluhr committed Jan 23, 2020
1 parent 2aa94b3 commit 4196627
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 206 deletions.
107 changes: 59 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,65 +32,75 @@ For more information about schema see examples on: https://github.com/jdorn/json

### Twig layout (

```
{{ use('beowulfenator/JsonEditor') }}
<div class="container">
<h1>Contact</h1>
{% if success %}
<div class="alert alert-success">
Your message has been sent. Thank you!
</div>
{% else %}
{{ use('yii/widgets/ActiveForm') }}
Form:
```twig
{{ use('dmstr/jsoneditor/JsonEditorWidget') }}
{{ use ('hrzg/widget/widgets') }}
{{ use('yii/widgets/ActiveForm') }}
{{ cell_widget({id: 'top'}) }}
<div class="row">
<div class="col-md-12">
{% set form = active_form_begin({
'id': 'contact-form',
'action' : '',
'options': {
}
}) %}
{{ this.registerJs('JSONEditor.plugins.selectize.enable = true;') }}
{{ json_editor_widget_widget(
{
'model': model,
'attribute': 'json',
'options': {
'id': 'contact-json'
},
'clientOptions': {
'theme': 'bootstrap3',
'disable_collapse': true,
'disable_edit_json': true,
'disable_properties': true,
'no_additional_properties': true,
'show_errors': 'always'
},
'schema': schema,
}
) }}
{{ html.submitButton('Send', {
'class': 'btn btn-primary',
}) | raw }}
{% set script %}
JSONEditor.defaults.language = "de";
JSONEditor.defaults.languages.de = {
error_minLength: "Muss mindestens \{\{\{0\}\} Zeichen enthalten.",
error_notset: "Muss gesetzt sein",
error_notempty: "Pflichtfeld"
};
{% endset %}
{{ this.registerJs(script) }}
{{ form.errorSummary(model) | raw }}
{{ active_form_end() }}
{% endif %}
{{ this.registerJs('JSONEditor.plugins.selectize.enable = true;') }}
{{ json_editor_widget_widget({
'model': model,
'attribute': 'json',
'options': {
'id': 'contact-json'
},
'clientOptions': {
'theme': 'bootstrap3',
'disable_collapse': true,
'disable_edit_json': true,
'disable_properties': true,
'no_additional_properties': true,
'show_errors': 'always'
},
'schema': schema,
}) }}
<button type="submit" class="btn btn-primary">{{ t('twig-widget', 'Send') }}</button>
{{ active_form_end() }}
</div>
</div>
{{ cell_widget({id: 'bottom'}) }}
```

### Settings schema
Done:
```twig
{{ use ('hrzg/widget/widgets') }}
{{ cell_widget({id: 'top'}) }}
<div class="alert alert-success">{{ t('twig-widget', 'Thank you for your message') }}</div>
{{ cell_widget({id: 'bottom'}) }}
```

### Settings schema

```json
{
"title": " ",
"type": "object",
Expand Down Expand Up @@ -228,12 +238,13 @@ For more information about schema see examples on: https://github.com/jdorn/json

## Giiant CRUDs

yii giiant-batch \
```bash
yii giiant-batch \
--tables=core_dmstr_contact_log \
--tablePrefix=core_dmstr \
--modelNamespace=hrzg\\contact\\models \
--modelQueryNamespace=hrzg\\contact\\models\\query \
--crudViewPath=@hrzg/contact/views/crud \
--crudControllerNamespace=hrzg\\contact\\controllers\\crud \
--crudSearchModelNamespace=hrzg\\contact\\models\\search
```
11 changes: 0 additions & 11 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@ class Module extends \yii\base\Module
/**
* @inheritdoc
*/
public $controllerNamespace = 'dmstr\modules\contact\controllers';
public $defaultRoute = 'crud/contact-log';
public $frontendLayout = '//main';

/**
* @inheritdoc
*/
public function init()
{
parent::init();

// custom initialization code goes here
}
}
Loading

0 comments on commit 4196627

Please sign in to comment.