mirror of
https://github.com/processwire/processwire.git
synced 2025-08-08 15:57:01 +02:00
Update ProcessPageEdit so that the template selection input (settings tab) is Ajax-loaded, like the parent selection input
This commit is contained in:
@@ -317,6 +317,7 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
||||
'confirm' => true,
|
||||
'ajaxChildren' => true,
|
||||
'ajaxParent' => true,
|
||||
'ajaxTemplate' => true,
|
||||
'editCrumbs' => false,
|
||||
);
|
||||
|
||||
@@ -1187,12 +1188,14 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
||||
$field->addOption(__('Native Fields', __FILE__), $options); // Optgroup label for sorting by fields native to ProcessWire
|
||||
|
||||
$customOptions = array();
|
||||
$fields = $caller->wire()->fields;
|
||||
$fieldsInfo = $fields->getAllValues(array('flags', 'type'), 'name');
|
||||
|
||||
foreach($caller->wire('fields') as $f) {
|
||||
foreach($fieldsInfo as $name => $f) {
|
||||
//if(!($f->flags & Field::flagAutojoin)) continue;
|
||||
if($f->flags & Field::flagSystem && $f->name != 'title' && $f->name != 'email') continue;
|
||||
if($f->type instanceof FieldtypeFieldsetOpen) continue;
|
||||
$customOptions[$f->name] = $f->name;
|
||||
if($f['flags'] & Field::flagSystem && $name != 'title' && $name != 'email') continue;
|
||||
if(wireInstanceOf($f['type'], 'FieldtypeFieldsetOpen')) continue;
|
||||
$customOptions[$name] = $name;
|
||||
}
|
||||
|
||||
ksort($customOptions);
|
||||
@@ -1316,17 +1319,18 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
||||
protected function buildFormTemplate() {
|
||||
|
||||
if($this->page->editable('template', false)) {
|
||||
/** @var Languages $languages */
|
||||
$languages = $this->wire('languages');
|
||||
/** @var Language $language */
|
||||
$language = $this->user->language;
|
||||
$languages = $this->wire()->languages;
|
||||
$language = $this->user->language; /** @var Language|null $language */
|
||||
$input = $this->wire()->input;
|
||||
$ajax = $this->configSettings['ajaxTemplate'];
|
||||
|
||||
/** @var InputfieldSelect $field */
|
||||
$field = $this->modules->get('InputfieldSelect');
|
||||
$field->attr('id+name', 'template');
|
||||
$field->attr('value', $this->page->template->id);
|
||||
$field->required = true;
|
||||
|
||||
$field->collapsed = Inputfield::collapsedYesAjax;
|
||||
if(!$ajax || $input->get('renderInputfieldAjax') === 'template' || $input->post('template') !== null) {
|
||||
foreach($this->getAllowedTemplates() as $template) {
|
||||
/** @var Template $template */
|
||||
$label = '';
|
||||
@@ -1334,13 +1338,14 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
||||
if(!$label) $label = $template->label ? $template->label : $template->name;
|
||||
$field->addOption($template->id, $label);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/** @var InputfieldMarkup $field */
|
||||
$field = $this->modules->get('InputfieldMarkup');
|
||||
$field->attr('value', "<p>" . $this->page->template->getLabel() . "</p>");
|
||||
$field->attr('value', "<p>" . $this->wire()->sanitizer->entities1($this->page->template->getLabel()) . "</p>");
|
||||
}
|
||||
|
||||
$field->label = $this->_('Template'); // Settings: Template field label
|
||||
$field->label = $this->_('Template') . ' (' . $this->page->template->getLabel() . ')'; // Settings: Template field label
|
||||
$field->icon = 'cubes';
|
||||
|
||||
return $field;
|
||||
@@ -2183,6 +2188,9 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
||||
*/
|
||||
protected function ___processInput(InputfieldWrapper $form, $level = 0, $formRoot = null) {
|
||||
|
||||
$input = $this->wire()->input;
|
||||
$languages = $this->wire()->languages;
|
||||
|
||||
static $skipFields = array(
|
||||
'sortfield_reverse',
|
||||
'submit_publish',
|
||||
@@ -2191,12 +2199,11 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
||||
);
|
||||
|
||||
if(!$level) {
|
||||
$form->processInput($this->input->post);
|
||||
$form->processInput($input->post);
|
||||
$formRoot = $form;
|
||||
$this->page->setQuietly('_forceAddStatus', 0);
|
||||
}
|
||||
|
||||
$languages = $this->wire()->languages;
|
||||
$errorAction = (int) $this->page->template->errorAction;
|
||||
|
||||
foreach($form as $inputfield) {
|
||||
@@ -2772,6 +2779,7 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
||||
|
||||
$allTemplates = count($this->predefinedTemplates) ? $this->predefinedTemplates : $this->wire('templates');
|
||||
|
||||
// note: this triggers load of all templates, fieldgroups and fields
|
||||
foreach($allTemplates as $template) {
|
||||
/** @var Template $template */
|
||||
|
||||
|
Reference in New Issue
Block a user