Ejemplo n.º 1
0
    }
    function to_database($prio)
    {
        return $prio instanceof Priority ? array($prio->getDesc(), $prio->getId()) : $prio;
    }
    function toString($value)
    {
        return $value instanceof Priority ? $value->getDesc() : $value;
    }
    function getConfigurationOptions()
    {
        return array('prompt' => new TextboxField(array('id' => 2, 'label' => 'Prompt', 'required' => false, 'default' => '', 'hint' => 'Leading text shown before a value is selected', 'configuration' => array('size' => 40, 'length' => 40))));
    }
}
FormField::addFieldTypes('Built-in Lists', function () {
    return array('priority' => array('Priority Level', PriorityField));
});
class Widget
{
    function __construct($field)
    {
        $this->field = $field;
        $this->name = $field->getFormName();
    }
    function parseValue()
    {
        $this->value = $this->getValue();
        if (!isset($this->value) && is_object($this->field->getAnswer())) {
            $this->value = $this->field->getAnswer()->getValue();
        }
        if (!isset($this->value) && isset($this->field->value)) {
Ejemplo n.º 2
0
    static function create($ht = false)
    {
        $inst = parent::create($ht);
        $inst->set('created', new SqlFunction('NOW'));
        return $inst;
    }
    static function getSelections()
    {
        $selections = array();
        foreach (DynamicList::objects() as $list) {
            $selections['list-' . $list->id] = array($list->getPluralName(), SelectionField, $list->get('id'));
        }
        return $selections;
    }
}
FormField::addFieldTypes('Custom Lists', array('DynamicList', 'getSelections'));
/**
 * Represents a single item in a dynamic list
 *
 * Fields:
 * value - (char * 255) Actual list item content
 * extra - (char * 255) Other values that represent the same item in the
 *      list, such as an abbreviation. In practice, should be a
 *      space-separated list of tokens which should hit this list item in a
 *      search
 * sort - (int) If sorting by this field, represents the numeric sort order
 *      that this item should come in the dropdown list
 */
class DynamicListItem extends VerySimpleModel
{
    static $meta = array('table' => LIST_ITEM_TABLE, 'pk' => array('id'), 'joins' => array('list' => array('null' => true, 'constraint' => array('list_id' => 'DynamicList.id'))));
Ejemplo n.º 3
0
    {
        $this->ht['default'] = '';
        if (!$this->_choices) {
            foreach (static::$_flags as $k => $v) {
                $this->_choices[$k] = $v['name'];
            }
        }
        return $this->_choices;
    }
    function getConfigurationOptions()
    {
        return array('prompt' => new TextboxField(array('id' => 2, 'label' => 'Prompt', 'required' => false, 'default' => '', 'hint' => 'Leading text shown before a value is selected', 'configuration' => array('size' => 40, 'length' => 40))));
    }
}
FormField::addFieldTypes('Dynamic Fields', function () {
    return array('flags' => array('Ticket Flags', TicketFlagField, false));
});
class FileUploadField extends FormField
{
    static $widget = 'FileUploadWidget';
    protected $attachments;
    static function getFileTypes()
    {
        static $filetypes;
        if (!isset($filetypes)) {
            $filetypes = YamlDataParser::load(INCLUDE_DIR . '/config/filetype.yaml');
        }
        return $filetypes;
    }
    function getConfigurationOptions()
    {