2008-09-29 05:18:23 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* EditableEmailField
|
2009-04-17 04:26:40 +02:00
|
|
|
*
|
2008-09-29 05:18:23 +02:00
|
|
|
* Allow users to define a validating editable email field for a UserDefinedForm
|
2009-04-17 04:26:40 +02:00
|
|
|
*
|
|
|
|
* @package userforms
|
2008-09-29 05:18:23 +02:00
|
|
|
*/
|
|
|
|
class EditableEmailField extends EditableFormField {
|
|
|
|
|
|
|
|
static $db = array(
|
|
|
|
"SendCopy" => "Boolean"
|
|
|
|
);
|
|
|
|
|
|
|
|
static $singular_name = 'Email field';
|
|
|
|
static $plural_name = 'Email fields';
|
|
|
|
|
|
|
|
function populateFromPostData( $data ) {
|
2009-04-21 05:44:13 +02:00
|
|
|
$this->SendCopy = !empty($data['SendCopy']) ? "1" : "0";
|
|
|
|
parent::populateFromPostData($data);
|
2008-09-29 05:18:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function ExtraOptions() {
|
|
|
|
$baseName = "Fields[$this->ID]";
|
|
|
|
|
|
|
|
$extraFields = new FieldSet(
|
|
|
|
new CheckboxField( $baseName . "[SendCopy]", _t('EditableEmailField.SENDCOPY', 'Send copy of submission to this address'), $this->SendCopy )
|
|
|
|
);
|
|
|
|
|
2009-04-21 05:44:13 +02:00
|
|
|
foreach(parent::ExtraOptions() as $extraField)
|
|
|
|
$extraFields->push($extraField);
|
2008-09-29 05:18:23 +02:00
|
|
|
|
2009-04-21 05:44:13 +02:00
|
|
|
if($this->readonly)
|
2008-09-29 05:18:23 +02:00
|
|
|
$extraFields = $extraFields->makeReadonly();
|
|
|
|
|
|
|
|
return $extraFields;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFormField() {
|
|
|
|
return new EmailField( $this->Name, $this->Title, $this->getField('Default') );
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFilterField() {
|
2009-04-21 05:44:13 +02:00
|
|
|
return $this->createField(true);
|
2008-09-29 05:18:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function DefaultField() {
|
|
|
|
$disabled = ($this->readonly) ? " disabled=\"disabled\"" : '';
|
|
|
|
|
2009-01-23 04:14:57 +01:00
|
|
|
return '<div class="field text"><label class="left">'._t('EditableEmailField.DEFAULTTEXT', 'Default Text').' </label><input class="defaultText" name="Fields['.Convert::raw2att( $this->ID ).'][Default]" type="text" value="'.Convert::raw2att( $this->getField('Default') ).'"'.$disabled.' /></div>';
|
2008-09-29 05:18:23 +02:00
|
|
|
}
|
2009-04-21 05:44:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the validation information related to this field. This is
|
|
|
|
* interrupted as a JSON object for validate plugin and used in the
|
|
|
|
* PHP.
|
|
|
|
*
|
|
|
|
* @see http://docs.jquery.com/Plugins/Validation/Methods
|
|
|
|
* @return Array
|
|
|
|
*/
|
|
|
|
public function getValidation() {
|
|
|
|
return array(
|
|
|
|
'email' => true
|
|
|
|
);
|
|
|
|
}
|
2008-09-29 05:18:23 +02:00
|
|
|
}
|
|
|
|
?>
|