本文整理汇总了PHP中Engine_Form::enableForm方法的典型用法代码示例。如果您正苦于以下问题:PHP Engine_Form::enableForm方法的具体用法?PHP Engine_Form::enableForm怎么用?PHP Engine_Form::enableForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine_Form
的用法示例。
在下文中一共展示了Engine_Form::enableForm方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAdditionalOptionsElement
public function getAdditionalOptionsElement()
{
$subform = new Zend_Form_SubForm(array('name' => 'extra', 'order' => 1000000, 'decorators' => array('FormElements')));
Engine_Form::enableForm($subform);
$subform->addElement('Checkbox', 'has_photo', array('label' => 'Only Members With Photos', 'decorators' => array('ViewHelper', array('Label', array('placement' => 'APPEND', 'tag' => 'label')), array('HtmlTag', array('tag' => 'li')))));
$subform->addElement('Checkbox', 'is_online', array('label' => 'Only Online Members', 'decorators' => array('ViewHelper', array('Label', array('placement' => 'APPEND', 'tag' => 'label')), array('HtmlTag', array('tag' => 'li')))));
$subform->addElement('Button', 'done', array('label' => 'Search', 'onclick' => 'javascript:searchMembers()', 'ignore' => true));
$this->addSubForm($subform, $subform->getName());
return $this;
}
示例2: generate
public function generate()
{
// get the search structure
$structure = Engine_Api::_()->getApi('core', 'fields')->getFieldsStructureSearch($this->_fieldType, $this->_topLevelId, $this->_topLevelValue);
$globalOrderIndex = 100;
$normalOrderIndex = 1000;
// Start firing away
foreach ($structure as $map) {
$field = $map->getChild();
// Ignore fields not searchable (even though getFieldsStructureSearch should have skipped it already)
if (!$field->search) {
continue;
}
$isGlobal = $map->field_id == 0 || $field->search == 2 || $map->field_id == $this->_topLevelId && $map->option_id == $this->_topLevelValue;
// Get search key
$key = null;
if (!empty($field->alias)) {
$key = $field->alias;
} else {
$key = sprintf('field_%d', $field->field_id);
}
// Get params
$params = $field->getElementParams($this->_fieldType, array('required' => false));
// Add attribs
if (!@is_array($params['options']['attribs'])) {
$params['options']['attribs'] = array();
}
$params['options']['attribs']['class'] = 'field_toggle' . ' ' . 'parent_' . $map->field_id . ' ' . 'option_' . $map->option_id . ' ' . 'field_' . $map->child_id . ' ';
if ($isGlobal) {
$params['options']['attribs']['class'] .= ' field_toggle_nohide';
}
$params['options']['attribs']['onchange'] = 'changeFields();';
//$params['options']['attribs']['id'] = $map->getKey();
// Remove some stuff
unset($params['options']['required']);
unset($params['options']['allowEmpty']);
unset($params['options']['validators']);
// Change decorators
$params['options']['decorators'] = array('ViewHelper', array('Label', array('tag' => 'span')), array('HtmlTag', array('tag' => 'li', 'style' => !$isGlobal ? 'display:none;' : '')));
// Change order
if ($isGlobal) {
$params['options']['order'] = $globalOrderIndex++;
} else {
$params['options']['order'] = $normalOrderIndex++;
}
// Get generic type
$info = Engine_Api::_()->fields()->getFieldInfo($field->type);
$genericType = null;
if (!empty($info['base'])) {
$genericType = $info['base'];
} else {
$genericType = $field->type;
}
$params['type'] = $genericType;
// For now
// Hack birthdate->age
if ($field->type == 'birthdate') {
$params['type'] = 'Select';
$params['options']['label'] = Zend_Registry::get('Zend_Translate')->translate('Age');
$params['options']['disableTranslator'] = true;
$multiOptions = array('' => ' ');
$min_age = 13;
if (isset($field->config['min_age'])) {
$min_age = $field->config['min_age'];
}
for ($i = $min_age; $i <= 100; $i++) {
$multiOptions[$i] = $i;
}
$params['options']['multiOptions'] = $multiOptions;
}
// Populate country multiOptions
if ($field->type == 'country') {
$locale = Zend_Registry::get('Locale');
$territories = Zend_Locale::getTranslationList('territory', $locale, 2);
asort($territories);
// fixes #1279
$params['options']['multiOptions'] = array_merge(array('' => ''), $territories);
}
// Ignored fields (these are hard-coded)
if (in_array($field->type, array('profile_type', 'first_name', 'last_name'))) {
continue;
}
// Hacks
switch ($genericType) {
// Ranges
case 'date':
case 'int':
case 'integer':
case 'float':
// Use subform
$subform = new Zend_Form_SubForm(array('description' => $params['options']['label'], 'order' => $params['options']['order'], 'decorators' => array('FormElements', array('Description', array('placement' => 'PREPEND', 'tag' => 'span')), array('HtmlTag', array('tag' => 'li', 'class' => 'browse-range-wrapper', 'style' => !$isGlobal ? 'display:none;' : '')))));
Fields_Form_Standard::enableForm($subform);
Engine_Form::enableForm($subform);
unset($params['options']['label']);
unset($params['options']['order']);
$params['options']['decorators'] = array('ViewHelper');
$subform->addElement($params['type'], 'min', $params['options']);
$subform->addElement($params['type'], 'max', $params['options']);
$this->addSubForm($subform, $key);
break;
//.........这里部分代码省略.........
示例3: init
public function init()
{
$this->setAttrib('id', 'admin-form')->setMethod('POST')->setAction($_SERVER['REQUEST_URI'])->setTitle('Create Network')->setDescription('NETWORK_FORM_ADMIN_NETWORK_DESCRIPTION');
// Set up form title/params
//if( !$isCreate ) {
// $this->setTitle('Edit Network');
//}
// set up hidden param
//if( !$isCreate ) {
// $network = Engine_Api::_()->network()->getNetwork($this->_networkIdentity);
//} else {
// $network = null;
//}
// init name
$this->addElement('Text', 'title', array('label' => 'Name', 'required' => true, 'allowEmpty' => false));
// init description
$this->addElement('Text', 'description', array('label' => 'Description', 'validators' => array(array('StringLength', true, array(6, 32)))));
// init assignment
$this->addElement('Radio', 'assignment', array('label' => 'Member Assignment', 'required' => true, 'allowEmpty' => false, 'multiOptions' => array('0' => 'Members can choose to join this network at any time', '1' => 'Members are automatically assigned to this network', '2' => 'Members must be assigned to this network by an administrator')));
// init field_id
$this->addElement('Select', 'field_id', array('label' => 'Related Profile Question', 'multiOptions' => array('' => '')));
// init fields
$fieldsMeta = Engine_Api::_()->fields()->getFieldsMeta("user");
$fieldTypes = array();
foreach ($fieldsMeta as $meta) {
$info = Engine_Api::_()->fields()->getFieldInfo($meta->type);
$genericType = $meta->type;
if (!empty($info['base'])) {
$genericType = $info['base'];
}
$id = 'field_pattern_' . $meta->field_id;
$pattern_type = null;
switch ($genericType) {
// Select
case 'select':
case 'radio':
case 'multiselect':
case 'multi_checkbox':
$pattern_type = 'select';
$options = $meta->getOptions();
if (empty($options)) {
continue;
}
$multiOptions = array();
foreach ($options as $option) {
$multiOptions[$option->option_id] = $option->label;
}
$this->addElement('Select', $id, array('label' => 'Matching Value', 'multiOptions' => $multiOptions));
break;
// Text
// Text
case 'text':
case 'textarea':
$pattern_type = 'text';
$this->addElement('Text', $id, array('label' => 'Matching Value'));
break;
// Range - birthday
// Range - birthday
case 'date':
case 'birthdate':
case 'birthday':
$pattern_type = 'date';
$subform = new Zend_Form_SubForm(array());
Engine_Form::enableForm($subform);
$subform->addElement('Date', 'min', array('label' => 'From:'));
$subform->addElement('Date', 'max', array('label' => 'To:'));
$this->addSubForm($subform, $id);
//$this->$id->getDecorator();
break;
// Range
// Range
case 'integer':
case 'float':
$pattern_type = 'range';
$subform = new Zend_Form_SubForm(array());
Engine_Form::enableForm($subform);
$subform->addElement($genericType, 'min', array('label' => 'From:'));
$subform->addElement($genericType, 'max', array('label' => 'To:'));
$this->addSubForm($subform, $id);
break;
// Unknown
// Unknown
default:
continue 2;
break;
}
$el = $this->{$id};
if ($el instanceof Zend_Form_SubForm) {
$el->setDecorators(array(array('FormElements'), array('HtmlTag', array('tag' => 'div', 'class' => 'form-wrapper network_field_container', 'id' => $id . '-wrapper', 'style' => 'display:none'))));
} else {
if ($el instanceof Zend_Form_Element) {
$el->getDecorator('HtmlTag2')->setOption('class', 'form-wrapper network_field_container')->setOption('style', 'display:none');
} else {
continue;
}
}
$fieldTypes[$meta->field_id] = $pattern_type;
$this->field_id->addMultiOption($meta->field_id, $meta->label);
}
// Field types
//.........这里部分代码省略.........