/** * Process and render search results. Uses the Lucene_results.ss template to * render the form. * * @access public * @param array $data The raw request data submitted by user * @param Form $form The form instance that was submitted * @param SS_HTTPRequest $request Request generated for this action * @return String The rendered form, for inclusion into the page template. */ public function ZendSearchLuceneResults($data, $form, $request) { $querystring = $form->dataFieldByName('Search')->dataValue(); $query = Zend_Search_Lucene_Search_QueryParser::parse($querystring); $hits = ZendSearchLuceneWrapper::find($query); $data = $this->getDataArrayFromHits($hits, $request); return $this->owner->customise($data)->renderWith(array('Lucene_results', 'Page')); }
function EditForm() { $member = Member::currentUser(); if ($member) { list($fields, $requiredFields) = MerchantAdminDOD::get_edit_fields(); $actions = new FieldSet(new FormAction('save', _t('MerchantAdminAccountPage_Controller.SAVE_DETAILS', 'Save Details'))); $form = new Form($this, 'EditForm', $fields, $actions, $requiredFields); $form->loadDataFrom($member); $form->dataFieldByName("Password")->setValue(""); return $form; } }
/** * Server-side validation * * This method checks if the entered identity URL is unique. * * @param array $data User submitted data * @param Form $form The used form * @return bool Returns TRUE if the submitted data is valid, otherwise * FALSE. */ function updatePHP(array $data, Form &$form) { if (!isset($data['IdentityURL']) || strlen(trim($data['IdentityURL'])) == 0) { return true; } $member = DataObject::get_one('Member', "IdentityURL = '" . Convert::raw2sql($data['IdentityURL']) . "'"); // if we are in a complex table field popup, use ctf[childID], else use // ID $id = null; if (isset($_REQUEST['ctf']['childID'])) { $id = $_REQUEST['ctf']['childID']; } elseif (isset($_REQUEST['ID'])) { $id = $_REQUEST['ID']; } if (is_object($member) && $member->ID != $id) { $field = $form->dataFieldByName('IdentityURL'); $this->owner->validationError($field->id(), _t('Security.MEMBERALREADYEXISTS', "There already exists a member with this identity URL"), "required"); return false; } return true; }
function testLink() { // A TableListField must be inside a form for its links to be generated $form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldSet(new TableListField("Tester", "TableListFieldTest_Obj", array("A" => "Col A", "B" => "Col B", "C" => "Col C", "D" => "Col D", "E" => "Col E"))), new FieldSet()); $table = $form->dataFieldByName('Tester'); $this->assertEquals($table->Link('test'), sprintf('TableListFieldTest_TestController/TestForm/field/Tester/test?SecurityID=%s', $form->dataFieldByName('SecurityID')->Value())); }
/** * Server-side validation * * This method checks if the entered account identifier is unique. * * @param array $data User submitted data * @param Form $form The used form * @return bool Returns TRUE if the submitted data is valid, otherwise * FALSE. */ function updatePHP(array $data, Form &$form) { if (!isset($data['External_Anchor']) || strlen(trim($data['External_Anchor'])) == 0 || !isset($data['External_SourceID']) || strlen($data['External_SourceID']) == 0) { return true; } $member = DataObject::get_one('Member', '"External_Anchor" = \'' . Convert::raw2sql($data['External_Anchor']) . '\' AND "External_SourceID" = \'' . Convert::raw2sql($data['External_SourceID']) . '\''); // if we are in a complex table field popup, use ctf[childID], else use // ID $id = null; if (isset($_REQUEST['ctf']['childID'])) { $id = $_REQUEST['ctf']['childID']; } elseif (isset($_REQUEST['ID'])) { $id = $_REQUEST['ID']; } if (is_object($member) && $member->ID != $id) { $field = $form->dataFieldByName('External_Anchor'); $this->owner->validationError($field->id(), _t('ExternalAuthenticator.UserExists', 'There already exists a member with this account name'), 'required'); return false; } return true; }
/** * Check that a DataObjectSet can be passed to TableListField */ function testDataObjectSet() { $one = new TableListFieldTest_Obj(); $one->A = "A-one"; $two = new TableListFieldTest_Obj(); $two->A = "A-two"; $three = new TableListFieldTest_Obj(); $three->A = "A-three"; $list = new ArrayList(array($one, $two, $three)); // A TableListField must be inside a form for its links to be generated $form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldList(new TableListField("Tester", $list, array("A" => "Col A", "B" => "Col B", "C" => "Col C", "D" => "Col D", "E" => "Col E"))), new FieldList()); $table = $form->dataFieldByName('Tester'); $rendered = $table->FieldHolder(); $this->assertContains('A-one', $rendered); $this->assertContains('A-two', $rendered); $this->assertContains('A-three', $rendered); }