public function setup() { parent::setup(); if (isset($this['value'])) { sfSympalFormToolkit::changeContentSlotValueWidget($this->object->sfSympalContentSlot, $this); } }
protected function setupValueField() { if (isset($this['value'])) { $this->useFields(array('value', 'type')); sfSympalFormToolkit::changeContentSlotValueWidget($this->object, $this); } }
/** * Retrieves the form class used to edit slot for "column slots". * * This is used by sfSympalFormToolkit::changeContentSlotValueWidget() * to extract the widget & validator out so we can put it into the * content slot form * * @return sfForm */ protected function _getContentSlotColumnForm() { $content = $this->getContentRenderedFor(); $contentTable = $content->getTable(); if ($contentTable->hasField($this->name)) { $formClass = sfSympalConfig::get('inline_editing', 'default_column_form'); $form = new $formClass($content); $form->useFields(array($this->name)); /* * For "column" slots, the widget and validator of the type are * not set automatically in the form itself (as opposed to true * slots who use sfSympalContentSlotForm, where the widget and * validator are setup automatically. This is a shortcoming. We * manually set the widget and validator here for content slots */ sfSympalFormToolkit::changeContentSlotValueWidget($this, $form); } if (sfSympalConfig::isI18nEnabled('sfSympalContent')) { $contentTranslationTable = Doctrine::getTable('sfSympalContentTranslation'); if ($contentTranslationTable->hasField($this->name)) { $formClass = sfSympalConfig::get('inline_editing', 'default_column_form'); $form = new $formClass($content); $form->useFields(array(sfContext::getInstance()->getUser()->getEditCulture())); /* * @TODO There should be a changeContentSlotValueWidget() call here, * but I don't seem to have access to the underlying translation * form, which is what you really want to pass into that function */ } } $contentTypeClassName = $content->getContentTypeClassName(); $contentTypeFormClassName = sfSympalConfig::get($contentTypeClassName, 'default_inline_editing_column_form', $contentTypeClassName . 'Form'); $contentTypeTable = Doctrine_Core::getTable($contentTypeClassName); if ($contentTypeTable->hasField($this->name)) { $form = new $contentTypeFormClassName($content->getRecord()); $form->useFields(array($this->name)); //See above note about this sfSympalFormToolkit::changeContentSlotValueWidget($this, $form); } if (sfSympalConfig::isI18nEnabled($contentTypeClassName)) { $contentTypeTranslationClassName = $contentTypeClassName . 'Translation'; $contentTypeTranslationFormClassName = sfSympalConfig::get($contentTypeTranslationClassName, 'default_inline_editing_column_form', $contentTypeTranslationClassName . 'Form'); $contentTypeTranslationTable = Doctrine_Core::getTable($contentTypeTranslationClassName); if ($contentTypeTranslationTable->hasField($this->name)) { $form = new $contentTypeFormClassName($content->getRecord()); $i18nForm = $form->getEmbeddedForm($language = sfContext::getInstance()->getUser()->getEditCulture()); $i18nForm->useFields(array($this->name)); //See above note about this sfSympalFormToolkit::changeContentSlotValueWidget($this, $form); unset($form[$language]); $form->embedForm($language, $i18nForm); $form->useFields(array($language)); } } if (!$form) { throw new InvalidArgumentException('Invalid content slot'); } return $form; }