mirror of
https://github.com/e107inc/e107.git
synced 2025-08-16 19:44:09 +02:00
Form Handler: renderElement() and renderValue() now support json values. (used by Pages/Menus custom fields)
This commit is contained in:
@@ -335,8 +335,8 @@ class page_chapters_form_ui extends e_admin_form_ui
|
||||
|
||||
function chapter_fields($curVal,$mode,$parm)
|
||||
{
|
||||
$fieldAmount = (deftrue('e_DEBUG')) ? 20 :10;
|
||||
|
||||
$frm = e107::getForm();
|
||||
|
||||
if($mode == 'read')
|
||||
{
|
||||
@@ -372,13 +372,32 @@ class page_chapters_form_ui extends e_admin_form_ui
|
||||
<tr><th>".LAN_NAME."</th><th>".LAN_TITLE."</th><th>".LAN_TYPE."</th><th>Params</th><th>".LAN_TOOLTIP."</th></tr>
|
||||
";
|
||||
|
||||
for ($i = 0; $i <= 20; $i++)
|
||||
|
||||
|
||||
|
||||
|
||||
for ($i = 0; $i <= $fieldAmount; $i++)
|
||||
{
|
||||
|
||||
$writeParms = array(
|
||||
'class' => 'e-ajax',
|
||||
'useValues' => 1,
|
||||
'default' => 'blank',
|
||||
'data-src' => e_REQUEST_URI,
|
||||
|
||||
);
|
||||
|
||||
$parmsWriteParms= array(
|
||||
'size' => 'block-level',
|
||||
'placeholder' => $this->getCustomFieldPlaceholder($value[$i]['type'])
|
||||
|
||||
);
|
||||
|
||||
$fieldName = $this->text('chapter_fields['.$i.'][key]',$value[$i]['key'],30, array('pattern'=>'^[a-z0-9-]*'));
|
||||
$fieldTitle = $this->text('chapter_fields['.$i.'][title]',$value[$i]['title'], 80);
|
||||
$fieldType = $this->select('chapter_fields['.$i.'][type]',$this->getFieldTypes(),$value[$i]['type'], 'useValues=1&default=blank');
|
||||
$fieldParms = $this->text('chapter_fields['.$i.'][writeParms]',$value[$i]['writeParms'], 80, array('size'=>'block-level'));
|
||||
$fieldHelp = $this->text('chapter_fields['.$i.'][help]',$value[$i]['help'], 80, array('size'=>'block-level'));
|
||||
$fieldType = $this->select('chapter_fields['.$i.'][type]',$this->getFieldTypes(),$value[$i]['type'], $writeParms);
|
||||
$fieldParms = $this->text('chapter_fields['.$i.'][writeParms]',$value[$i]['writeParms'], 255, $parmsWriteParms);
|
||||
$fieldHelp = $this->text('chapter_fields['.$i.'][help]',$value[$i]['help'], 255, array('size'=>'block-level'));
|
||||
$text .= "<tr><td>".$fieldName."</td><td>".$fieldTitle."</td><td>".$fieldType."</td><td>".$fieldParms."</td><td>".$fieldHelp."</td></tr>";
|
||||
}
|
||||
|
||||
@@ -399,8 +418,37 @@ class page_chapters_form_ui extends e_admin_form_ui
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//@XXX Move to Form-handler?
|
||||
public function getCustomFieldPlaceholder($type)
|
||||
{
|
||||
switch($type)
|
||||
{
|
||||
case "radio":
|
||||
case "dropdown":
|
||||
case "checkboxes":
|
||||
return 'eg. { "optArray": { "blue": "Blue", "green": "Green", "red": "Red" }, "default": "blank" }';
|
||||
break;
|
||||
|
||||
case "tags":
|
||||
return 'eg. tag1,tag2,tag3,tag4';
|
||||
break;
|
||||
|
||||
case "datestamp":
|
||||
return 'eg. (Optional) { "format": "yyyy-mm-dd" }';
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Override the default Options field.
|
||||
function options($parms, $value, $id, $attributes)
|
||||
@@ -785,8 +833,18 @@ class page_admin_ui extends e_admin_ui
|
||||
$this->fields['page_chapter']['writeParms']['ajax'] = array('src'=>e_SELF."?mode=page&action=chapter-change",'target'=>'tabadditional');
|
||||
}
|
||||
|
||||
|
||||
if(e_AJAX_REQUEST)
|
||||
{
|
||||
// @todo insert placeholder examples in params input when 'type' dropdown value is changed
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(e_AJAX_REQUEST && isset($_POST['page_chapter']) ) //&& $this->getAction() === 'chapter-change'
|
||||
{
|
||||
|
||||
$this->initCustomFields($_POST['page_chapter']);
|
||||
|
||||
$elid = 'core-page-create';
|
||||
@@ -821,7 +879,9 @@ class page_admin_ui extends e_admin_ui
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @todo Move to admin-ui ?
|
||||
*/
|
||||
private function initCustomFields($chap=null)
|
||||
{
|
||||
$tabId = 'additional';
|
||||
@@ -835,7 +895,24 @@ class page_admin_ui extends e_admin_ui
|
||||
$fld['tab'] = $tabId;
|
||||
$fld['data'] = false;
|
||||
|
||||
if($fld['type'] === 'icon')
|
||||
{
|
||||
$fld['writeParms'] .= "&glyphs=1";
|
||||
}
|
||||
|
||||
if($fld['type'] == 'checkboxes')
|
||||
{
|
||||
if($tmp = e107::getParser()->isJSON($fld['writeParms']))
|
||||
{
|
||||
$fld['writeParms'] = $tmp;
|
||||
}
|
||||
|
||||
$fld['writeParms']['useKeyValues'] = 1;
|
||||
}
|
||||
|
||||
|
||||
$this->fields['page_fields__'.$key] = $fld;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -879,19 +956,11 @@ class page_admin_ui extends e_admin_ui
|
||||
|
||||
parent::EditObserver();
|
||||
|
||||
if(!deftrue('e_DEBUG'))
|
||||
{
|
||||
// return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$row = e107::getDb()->retrieve('page', 'page_chapter, page_fields', 'page_id='.$this->getId());
|
||||
$chap = intval($row['page_chapter']);
|
||||
$this->initCustomFields($chap);
|
||||
$this->loadCustomFieldsData();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -928,6 +997,11 @@ class page_admin_ui extends e_admin_ui
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Overrid
|
||||
*/
|
||||
|
Reference in New Issue
Block a user