本文整理汇总了PHP中sfForm::isBound方法的典型用法代码示例。如果您正苦于以下问题:PHP sfForm::isBound方法的具体用法?PHP sfForm::isBound怎么用?PHP sfForm::isBound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfForm
的用法示例。
在下文中一共展示了sfForm::isBound方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: embedMergeForm
/**
* Embeds a form like "mergeForm" does, but will still
* save the input data.
*/
public function embedMergeForm($name, sfForm $form)
{
// This starts like sfForm::embedForm
$name = (string) $name;
if (true === $this->isBound() || true === $form->isBound()) {
throw new LogicException('A bound form cannot be merged');
}
$this->embeddedForms[$name] = $form;
$form = clone $form;
unset($form[self::$CSRFFieldName]);
// But now, copy each widget instead of the while form into the current
// form. Each widget ist named "formname|fieldname".
foreach ($form->getWidgetSchema()->getFields() as $field => $widget) {
$widgetName = "{$name}|{$field}";
if (isset($this->widgetSchema[$widgetName])) {
throw new LogicException("The forms cannot be merged. A field name ’{$widgetName’} already exists.");
}
$this->widgetSchema[$widgetName] = $widget;
// Copy widget
$this->validatorSchema[$widgetName] = $form->validatorSchema[$field];
// Copy schema
$this->setDefault($widgetName, $form->getDefault($field));
// Copy default value
if (!$widget->getLabel()) {
// Re-create label if not set (otherwise it would be named ’ucfirst($widgetName)’)
$label = $form->getWidgetSchema()->getFormFormatter()->generateLabelName($field);
$this->getWidgetSchema()->setLabel($widgetName, $label);
}
}
// And this is like in sfForm::embedForm
$this->resetFormFields();
}
示例2: mergeForm
/**
* Merges current form widget and validator schemas with the ones from the
* sfForm object passed as parameter. Please note it also merge defaults.
*
* @param sfForm $form The sfForm instance to merge with current form
*
* @throws LogicException If one of the form has already been bound
*/
public function mergeForm(sfForm $form)
{
if (true === $this->isBound() || true === $form->isBound()) {
throw new LogicException('A bound form cannot be merged');
}
$form = clone $form;
unset($form[self::$CSRFFieldName]);
$this->defaults = array_merge($this->defaults, $form->getDefaults());
foreach ($form->getWidgetSchema()->getPositions() as $field) {
$this->widgetSchema[$field] = $form->getWidget($field);
}
foreach ($form->getValidatorSchema()->getFields() as $field => $validator) {
$this->validatorSchema[$field] = $validator;
}
$this->getWidgetSchema()->setLabels(array_merge($this->getWidgetSchema()->getLabels(), $form->getWidgetSchema()->getLabels()));
$this->getWidgetSchema()->setHelps(array_merge($this->getWidgetSchema()->getHelps(), $form->getWidgetSchema()->getHelps()));
$this->mergePreValidator($form->getValidatorSchema()->getPreValidator());
$this->mergePostValidator($form->getValidatorSchema()->getPostValidator());
$this->resetFormFields();
}
示例3: getVisibleColumns
/**
* Compute different sources to get the columns that must be showed
* 1) from form request 2) from session 3) from default value
* @param sfBasicSecurityUser $user the user
* @param sfForm $form The filter form with the 'col_fields' field defined
* @param bool $as_string specify if you want the return to be a string (concat of visible cols)
* @return array of fields with check or uncheck or a list of visible fields separated by |
*/
private function getVisibleColumns(sfBasicSecurityUser $user, sfForm $form, $as_string = false)
{
$flds = array('category', 'collection', 'taxon', 'type', 'gtu', 'codes', 'chrono', 'ig', 'acquisition_category', 'litho', 'lithologic', 'mineral', 'expedition', 'type', 'individual_type', 'sex', 'state', 'stage', 'social_status', 'rock_form', 'individual_count', 'part', 'object_name', 'part_status', 'building', 'floor', 'room', 'row', 'col', 'shelf', 'container', 'container_type', 'container_storage', 'sub_container', 'sub_container_type', 'sub_container_storage', 'specimen_count', 'part_codes', 'loans');
$flds = array_fill_keys($flds, 'uncheck');
if ($form->isBound() && $form->getValue('col_fields') != "") {
$req_fields = $form->getValue('col_fields');
$req_fields_array = explode('|', $req_fields);
} else {
$req_fields_array = $user->fetchVisibleCols();
}
if (empty($req_fields_array)) {
$req_fields_array = explode('|', $form->getDefault('col_fields'));
}
if ($as_string) {
return implode('|', $req_fields_array);
}
foreach ($req_fields_array as $k => $val) {
$flds[$val] = 'check';
}
return $flds;
}
示例4: getVisibleColumns
/**
* Compute different sources to get the columns that must be showed
* 1) from form request 2) from session 3) from default value
* @param sfForm $form The form with the 'fields' field defined
* @return array of fields with check or uncheck or a list of visible fields separated by |
*/
private function getVisibleColumns(sfForm $form)
{
$flds = array('category', 'collection', 'taxon', 'type', 'gtu', 'chrono', 'taxon_common_name', 'chrono_common_name', 'litho_common_name', 'lithologic_common_name', 'mineral_common_name', 'expedition', 'individual_type', 'litho', 'lithologic', 'mineral', 'sex', 'state', 'stage', 'social_status', 'rock_form', 'specimen_count', 'object_name');
$flds = array_fill_keys($flds, 'uncheck');
if ($form->isBound()) {
$req_fields = $form->getValue('col_fields');
if ($form->getValue('taxon_common_name') != '' || $form->getValue('taxon_name') != '') {
$req_fields .= '|taxon|taxon_common_name';
}
if ($form->getValue('chrono_common_name') != '' || $form->getValue('chrono_name') != '') {
$req_fields .= '|chrono|chrono_common_name';
}
if ($form->getValue('litho_common_name') != '' || $form->getValue('litho_name') != '') {
$req_fields .= '|litho|litho_common_name';
}
if ($form->getValue('lithology_common_name') != '' || $form->getValue('lithology_name') != '') {
$req_fields .= '|lithologic|lithology_common_name';
}
if ($form->getValue('mineral_common_name') != '' || $form->getValue('mineral_name') != '') {
$req_fields .= '|mineral|mineral_common_name';
}
if ($form->getValue('search_type', 'zoo') == 'zoo') {
if (!strpos($req_fields, 'common_name')) {
$req_fields .= '|taxon|taxon_common_name';
// add taxon by default if there is not other catalogue
}
} else {
if (!strpos($req_fields, 'common_name')) {
$req_fields .= '|chrono|litho|lithologic|mineral';
}
// add cols by default if there is not other catalogue
}
$req_fields_array = explode('|', $req_fields);
}
if (empty($req_fields_array)) {
$req_fields_array = explode('|', $form->getDefault('col_fields'));
}
foreach ($req_fields_array as $k => $val) {
$flds[$val] = 'check';
}
$form->setDefault('col_fields', $req_fields);
return $flds;
}
示例5: embedOptionalForm
/**
* Embeds an optional sfForm into the current form.
*
* @param string $name The field name
* @param sfForm $form A sfForm instance
* @param string $decorator A HTML decorator for the embedded form
* @param array $options An array of options passed to the sfWidgetFormSchemaOptional
*/
public function embedOptionalForm($name, sfForm $form, $decorator = null, $options = array())
{
$name = (string) $name;
if (true === $this->isBound() || true === $form->isBound())
{
throw new LogicException('A bound form cannot be embedded');
}
$form = clone $form;
unset($form[self::$CSRFFieldName]);
$this->setDefault($name, $form->getDefaults());
$widgetSchema = $form->getWidgetSchema();
$decorator = null === $decorator ? $widgetSchema->getFormFormatter()->getDecoratorFormat() : $decorator;
$this->widgetSchema[$name] = new sfWidgetFormSchemaOptional($widgetSchema, $decorator, $options);
$this->validatorSchema[$name] = new sfValidatorPass();
$this->resetFormFields();
}