- Disable options according to type too

- Start options, value & rows disabled according to type when popup opens
This commit is contained in:
Nathan Gray 2014-11-27 16:58:11 +00:00
parent 586656289d
commit 81ef504361
2 changed files with 22 additions and 6 deletions

View File

@ -80,11 +80,16 @@ class customfields
public static $type_attribute_flags = array(
'text' => array('cf_len' => true, 'cf_rows' => true),
'float' => array('cf_len' => true, 'cf_rows' => true),
'select' => array('cf_len' => false, 'cf_rows' => true),
'label' => array('cf_values' => true),
'select' => array('cf_len' => false, 'cf_rows' => true, 'cf_values' => true),
'date' => array('cf_len' => true, 'cf_rows' => false),
'date-time' => array('cf_len' => true, 'cf_rows' => false),
'select-account' => array('cf_len' => false, 'cf_rows' => true),
'htmlarea' => array('cf_len' => true, 'cf_rows' => true),
'button' => array('cf_values' => true),
'ajax_select' => array('cf_values' => true),
'radio' => array('cf_values' => true),
'checkbox' => array('cf_values' => true),
);
/**
@ -401,6 +406,14 @@ class customfields
$content['statustext'] = $content['options'][$content['cf_type']];
$content['attributes'] = self::$type_attribute_flags;
// Start disabled, but don't set read-only as that changes the widget to readonly
$this->tmpl->setElementAttribute('cf_len', 'disabled', true);
$this->tmpl->setElementAttribute('cf_rows', 'disabled', true);
foreach(array('cf_len','cf_rows','cf_values') as $field)
{
$this->tmpl->setElementAttribute($field, 'disabled', !self::$type_attribute_flags[$content['cf_type']][$field]);
}
$this->tmpl->exec('admin.customfields.edit',$content,$sel_options,$readonlys,array(
'cf_id' => $cf_id,
'cf_app' => $this->appname,
@ -432,14 +445,14 @@ class customfields
'default' => true,
'allowOnMultiple' => false,
'url' => 'menuaction=admin.customfields.edit&cf_id=$id&use_private='.$this->use_private,
'popup' => '450x380',
'popup' => '500x380',
'group' => $group=1,
'disableClass' => 'th',
),
'add' => array(
'caption' => 'Add',
'url' => 'menuaction=admin.customfields.edit&appname='.$this->appname.'&use_private='.$this->use_private,
'popup' => '450x380',
'popup' => '500x380',
'group' => $group,
),
'delete' => array(

View File

@ -2,9 +2,9 @@
<!-- $Id$ -->
<overlay>
<template id="admin.customfield_edit" template="" lang="" group="0" version="1.9.001">
<grid width="100%">
<grid width="450px">
<columns>
<column width="130"/>
<column width="110"/>
<column width="350"/>
<column width="45"/>
<column width="30"/>
@ -28,7 +28,10 @@
</row>
<row>
<description value="Type of field"/>
<customfields-types statustext="Type of customfield" id="cf_type" class="et2_fullWidth" span="2" onchange="widget.getRoot().getWidgetById('cf_values').set_statustext(widget.getArrayMgr('content').getEntry('options['+widget.getValue()+']')||'');widget.getRoot().getWidgetById('cf_len').set_disabled(!widget.getArrayMgr('content').getEntry('attributes['+widget.getValue()+'][cf_len]'));widget.getRoot().getWidgetById('cf_rows').set_disabled(!widget.getArrayMgr('content').getEntry('attributes['+widget.getValue()+'][cf_rows]'));"/>
<customfields-types statustext="Type of customfield" id="cf_type" class="et2_fullWidth" span="2" onchange="widget.getRoot().getWidgetById('cf_values').set_statustext(widget.getArrayMgr('content').getEntry('options['+widget.getValue()+']')||'');
widget.getRoot().getWidgetById('cf_len').set_disabled(!widget.getArrayMgr('content').getEntry('attributes['+widget.getValue()+'][cf_len]'));
widget.getRoot().getWidgetById('cf_rows').set_disabled(!widget.getArrayMgr('content').getEntry('attributes['+widget.getValue()+'][cf_rows]'));
widget.getRoot().getWidgetById('cf_values').set_disabled(!widget.getArrayMgr('content').getEntry('attributes['+widget.getValue()+'][cf_values]'));"/>
<hbox span="2">
<description value="Required"/>
<checkbox id="cf_needed"/>