public function updateEditForm(Form $form)
 {
     $locale = isset($_REQUEST['locale']) ? $_REQUEST['locale'] : $_REQUEST['Locale'];
     if (!empty($locale) && i18n::validate_locale($locale) && singleton('SiteConfig')->has_extension('Translatable') && (Translatable::get_allowed_locales() === null || in_array($locale, (array) Translatable::get_allowed_locales(), false)) && $locale != Translatable::get_current_locale()) {
         $orig = Translatable::get_current_locale();
         Translatable::set_current_locale($locale);
         $formAction = $form->FormAction();
         $form->setFormAction($formAction);
         Translatable::set_current_locale($orig);
     }
 }
 /**
  * Updates the edit form object from AssetAdmin to provide a workaround for a bug in Secure Assets.
  *
  * @param Form $form
  */
 public function updateEditForm($form)
 {
     if ($this->isAssetAdmin() && $this->hasSecureAssets()) {
         if (($record = $form->getRecord()) && $record instanceof Folder) {
             if ($field = $form->Fields()->dataFieldByName('ViewerGroups')) {
                 // Create Form Object:
                 $dummy = Form::create($this->owner, 'EditForm', FieldList::create(), FieldList::create());
                 // Populate Form Data:
                 $dummy->loadDataFrom($record);
                 // Define Form Action (allows ViewerGroups field to work in asset EditForm):
                 $dummy->setFormAction(sprintf('%s/field/File/item/%d/ItemEditForm', $form->FormAction(), $record->ID));
                 // Update Field Object:
                 $field->setForm($dummy);
             }
         }
     }
 }
Example #3
0
 /**
  * Return a Link to this field
  */
 public function Link($action = null)
 {
     return Controller::join_links($this->form->FormAction(), 'field/' . $this->name, $action);
 }
 /**
  * Form used for renaming a folder
  * @return {Form} Form to be used for renaming a folder
  */
 public function RenameFolderForm()
 {
     $folder = SnippetFolder::get()->byID(intval(str_replace('folder-', '', $this->request->getVar('ID'))));
     if (!empty($folder) && $folder !== false && $folder->ID != 0) {
         $fields = new FieldList(new TabSet('Root', new Tab('Main', 'Main', new TextField('Name', _t('SnippetFolder.NAME', '_Name'), null, 150))), new HiddenField('ID', 'ID'));
         $actions = new FieldList(new FormAction('doRenameFolder', _t('CodeBank.SAVE', '_Save')));
     } else {
         $fields = new FieldList();
         $actions = new FieldList();
     }
     $validator = new RequiredFields('Name');
     $form = new Form($this, 'RenameFolderForm', $fields, $actions, $validator);
     $form->addExtraClass('member-profile-form');
     //If no parent disable folder
     if (empty($folder) || $folder === false || $folder->ID == 0) {
         $form->setMessage(_t('CodeBank.FOLDER_NOT_FOUND', '_Folder could not be found'), 'bad');
     } else {
         $form->loadDataFrom($folder);
         $form->setFormAction(Controller::join_links($form->FormAction(), '?ID=' . $folder->ID));
     }
     return $form;
 }
Example #5
0
	/**
	 * Add the MultiFormSessionID variable to the URL on form submission.
	 * This is a means to persist the session, by adding it's identification
	 * to the URL, which ties it back to this MultiForm instance.
	 * 
	 * @return string
	 */
	function FormAction() {
		$action = parent::FormAction();
		$action .= (strpos($action, '?')) ? '&' : '?';
		$action .= "MultiFormSessionID={$this->session->Hash}";
		
		return $action;
	}
Example #6
0
 function FormAction()
 {
     return parent::FormAction() . (isset($_REQUEST['showqueries']) ? '&showqueries=1' : '');
 }
 /**
  * Add the MultiFormSessionID variable to the URL on form submission.
  * This is a means to persist the session, by adding it's identification
  * to the URL, which ties it back to this MultiForm instance.
  * 
  * @return string
  */
 function FormAction()
 {
     $action = parent::FormAction();
     $action .= strpos($action, '?') ? '&' : '?';
     $action .= "{$this->config()->get_var}={$this->session->Hash}";
     return $action;
 }