本文整理汇总了PHP中Zend_Form_SubForm::setDefaults方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_SubForm::setDefaults方法的具体用法?PHP Zend_Form_SubForm::setDefaults怎么用?PHP Zend_Form_SubForm::setDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_SubForm
的用法示例。
在下文中一共展示了Zend_Form_SubForm::setDefaults方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefaults
/**
* Override setDefaults to dynamically generate elements
* @param array $defaults
*/
public function setDefaults($defaults)
{
$subform = $this->getSubForm('current');
foreach ($defaults['current'] as $id => $values) {
$subform->addElement($this->createTaskElement($id, $values));
}
// set defaults, which will propagate to newly created subforms & elements
parent::setDefaults($defaults);
}
示例2: initForm
/**
*/
public function initForm(Zend_Form $form, ListView $list, MemberView $member = null)
{
$newsletter = new Zend_Form_SubForm();
$newsletter->addElement('checkbox', 'subscriber', array('label' => 'I want to receive newsletter'));
foreach ($list->groups as $group) {
$type = $group['form_field'] == 'radio' ? 'radio' : 'multiCheckbox';
$newsletter->addElement($type, $group['name'], array('label' => $group['name'], 'multioptions' => $group['groups']));
}
if ($member !== null) {
$newsletter->setDefaults(array_merge((array) $member, $member->groups));
}
$form->addSubForm($newsletter, 'newsletter');
}
示例3: setDefaults
/**
* Przeciążenie setDefaults, żeby uwzględniało prefixy w filtrach
*
* @return Zend_Form
*/
public function setDefaults(array $defaults)
{
if ($this->filteredData && isset($defaults[$this->filteredData])) {
$defaults = $defaults[$this->filteredData];
}
return parent::setDefaults($defaults);
}
示例4: addUserAttributesSubForm
/**
* Add user attributes subform to form
*
* @param Zend_Form $form
* @param Newscoop\Entity\User $user
* @return void
*/
private function addUserAttributesSubForm(Zend_Form $form, User $user)
{
$translator = \Zend_Registry::get('container')->getService('translator');
$subForm = new Zend_Form_SubForm();
$subForm->setLegend($translator->trans('User attributes', array(), 'users'));
foreach ($user->getRawAttributes() as $key => $val) {
$subForm->addElement('text', $key, array('label' => $key));
}
$subForm->setDefaults($user->getAttributes());
$form->addSubForm($subForm, 'attributes');
}