mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
#11 Can't create multilanguage categories fix
This commit is contained in:
parent
0f095eafa8
commit
351c5afd5d
@ -1,25 +1,39 @@
|
||||
{% extends "theme::layouts/default" %}
|
||||
{% block content %}
|
||||
{% include "theme::partials/messages" %}
|
||||
{% set form = form('cats','category').entry(id).get() %}
|
||||
{{ form_open()|raw }}
|
||||
<div class="container-fluid">
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
{{ form.fields.name|raw }}
|
||||
{{ form.fields.slug|raw }}
|
||||
<input type="hidden" name="parent_category"
|
||||
value="{% if form.fields.parent_category.value.id is defined %}{{ form.fields.parent_category.value.id }}{% elseif app.request.get('parent') is defined %}{{ app.request.get('parent') }}{% endif %}">
|
||||
{{ form.fields.order|raw }}
|
||||
{{ form.fields.files|raw }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="controls card">
|
||||
<div class="card-block">
|
||||
{{ form.actions|raw }}
|
||||
</div>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
|
||||
{% set actions = ['save'] %}
|
||||
|
||||
{% if id is not null %}
|
||||
{% set actions = ['update'] %}
|
||||
{% endif %}
|
||||
|
||||
{% set form = form('cats','category').entry(id).actions(actions).get() %}
|
||||
{{ form_open({
|
||||
'class': 'form ' ~ form.options.class ,
|
||||
'enctype': 'multipart/form-data',
|
||||
})|raw }}
|
||||
<fieldset>
|
||||
<div class="section">
|
||||
{{ nameField|raw }}
|
||||
{{ form.fields.slug|raw }}
|
||||
<input type="hidden" name="parent_category"
|
||||
value="{% if form.fields.parent_category.value.id is defined %}{{ form.fields.parent_category.value.id }}{% elseif app.request.get('parent') is defined %}{{ app.request.get('parent') }}{% endif %}">
|
||||
{{ form.fields.order|raw }}
|
||||
{{ form.fields.files|raw }}
|
||||
</div><!-- section -->
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
{{ form.close|raw}}
|
||||
<div class="controls card">
|
||||
<div class="card-block">
|
||||
{{ form.actions|raw }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ asset_add("scripts.js", "visiosoft.module.cats::js/admin-cat.js") }}
|
||||
{% endblock %}
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
use Anomaly\Streams\Platform\Model\Cats\CatsCategoryEntryModel;
|
||||
use Illuminate\Http\Request;
|
||||
use Sunra\PhpSimple\HtmlDomParser;
|
||||
use Visiosoft\CatsModule\Category\CategoryCollection;
|
||||
use Visiosoft\CatsModule\Category\CategoryModel;
|
||||
use Visiosoft\CatsModule\Category\Form\CategoryFormBuilder;
|
||||
@ -65,9 +66,21 @@ class CategoryController extends AdminController
|
||||
return $this->redirect->to('/admin/cats/create');
|
||||
}
|
||||
return $this->redirect->to('/admin/cats');
|
||||
} else {
|
||||
$form->setFields(['name']);
|
||||
$form->setActions(['save']);
|
||||
$formBuilder = $form;
|
||||
$nameField = HTMLDomParser::str_get_html($form->render()->getContent());
|
||||
$nameField = $nameField->find('.name', 0);
|
||||
if ($nameField !== null) {
|
||||
$nameField = $nameField->innertext();
|
||||
} else {
|
||||
$nameField = "";
|
||||
}
|
||||
}
|
||||
|
||||
return $this->view->make('visiosoft.module.cats::cats/admin-cat');
|
||||
|
||||
return $this->view->make('visiosoft.module.cats::cats/admin-cat', compact('nameField','formBuilder'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,8 +97,18 @@ class CategoryController extends AdminController
|
||||
if ($form->hasFormErrors()) {
|
||||
return $this->redirect->back();
|
||||
}
|
||||
} else {
|
||||
$form->setFields(['name']);
|
||||
$nameField = HTMLDomParser::str_get_html($form->render($id)->getContent());
|
||||
$nameField = $nameField->find('.name', 0);
|
||||
if ($nameField !== null) {
|
||||
$nameField = $nameField->innertext();
|
||||
} else {
|
||||
$nameField = "";
|
||||
}
|
||||
}
|
||||
return $this->view->make('visiosoft.module.cats::cats/admin-cat')->with('id', $id);
|
||||
|
||||
return $this->view->make('visiosoft.module.cats::cats/admin-cat', compact('nameField'))->with('id', $id);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user