Example #1
0
 static function register($name, $namespace, $view_dir)
 {
     $class = '\\Larakit\\QuickForm\\Element' . Str::studly($name);
     $cont = '\\HTML_QuickForm2_Container';
     if (trim($class, '\\') instanceof $cont) {
         self::$containers[] = $class;
     }
     $path = 'QuickForm/Element' . Str::studly($name) . '.php';
     \HTML_QuickForm2_Factory::registerElement($name, $class, $path);
     if (is_subclass_of($class, '\\HTML_QuickForm2_Container')) {
         self::container($class);
     }
     self::$elements[$name] = compact('class', 'namespace', 'view_dir');
 }
 public function testAddElementWithUnderscoreInType()
 {
     HTML_QuickForm2_Factory::registerElement('super_box', 'HTML_QuickForm2_Element_InputCheckbox');
     $this->assertTrue(HTML_QuickForm2_Factory::isElementRegistered('super_box'));
     $c = new HTML_QuickForm2_ContainerImpl('cCOT3');
     $el1 = $c->addSuper_Box('sBox_1');
     $el2 = $c->addsuper_box('sBox_2');
     $el3 = $c->addSuper_box('sBox_3');
     $this->assertSame($el1, $c->getElementById('sBox_1-0'));
     $this->assertSame($el2, $c->getElementById('sBox_2-0'));
     $this->assertSame($el3, $c->getElementById('sBox_3-0'));
     try {
         $c->addSuper_Select('sSel_1');
     } catch (HTML_QuickForm2_InvalidArgumentException $e) {
         $this->assertEquals("Element type 'super_select' is not known", $e->getMessage());
         return;
     }
     $this->fail('Expected HTML_QuickForm2_InvalidArgumentException was not thrown');
 }
Example #3
0
 public function testCreateElementValid()
 {
     HTML_QuickForm2_Factory::registerElement('fakeelement', 'FakeElement', dirname(__FILE__) . '/_files/FakeElement.php');
     $el = HTML_QuickForm2_Factory::createElement('fakeelement', 'fake', 'attributes', array('options' => '', 'label' => 'fake label'));
     $this->assertType('FakeElement', $el);
     $this->assertEquals('fake', $el->name);
     $this->assertEquals(array('options' => '', 'label' => 'fake label'), $el->data);
     $this->assertEquals('attributes', $el->attributes);
 }
    </div>
</div>
TPL;
        }
    }
    public function renderDualSelect(HTML_QuickForm2_Node $element)
    {
        $elTpl = $this->renderer->prepareTemplate($this->renderer->findTemplate($element), $element);
        foreach ($element->toArray() as $k => $v) {
            $elTpl = str_replace('{' . $k . '}', $v, $elTpl);
        }
        $this->renderer->html[count($this->renderer->html) - 1][] = str_replace('{id}', $element->getId(), $elTpl);
    }
}
// Now we register both the element and the renderer plugin
HTML_QuickForm2_Factory::registerElement('dualselect', 'HTML_QuickForm2_Element_DualSelect');
HTML_QuickForm2_Renderer::registerPlugin('default', 'HTML_QuickForm2_Renderer_Default_DualSelectPlugin');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <style type="text/css">
/* Set up custom font and form width */
body {
    margin-left: 10px;
    font-family: Arial,sans-serif;
    font-size: small;
}

.quickform {
Example #5
0
}
class Am_Form_Container_PrefixFieldset extends HTML_QuickForm2_Container_Group
{
    public function getType()
    {
        return 'fieldset';
    }
}
HTML_QuickForm2_Factory::registerElement('period', 'Am_Form_Element_Period');
HTML_QuickForm2_Factory::registerElement('date', 'Am_Form_Element_Date');
HTML_QuickForm2_Factory::registerElement('integer', 'Am_Form_Element_Integer');
HTML_QuickForm2_Factory::registerElement('advcheckbox', 'Am_Form_Element_AdvCheckbox');
HTML_QuickForm2_Factory::registerElement('advradio', 'Am_Form_Element_AdvRadio');
HTML_QuickForm2_Factory::registerElement('email_checkbox', 'Am_Form_Element_EmailCheckbox');
HTML_QuickForm2_Factory::registerElement('email_select', 'Am_Form_Element_EmailSelect');
HTML_QuickForm2_Factory::registerElement('email_link', 'Am_Form_Element_EmailLink');
HTML_QuickForm2_Factory::registerElement('email_with_days', 'Am_Form_Element_EmailWithDays');
HTML_QuickForm2_Factory::registerElement('upload', 'Am_Form_Element_Upload');
HTML_QuickForm2_Factory::registerElement('script', 'Am_Form_Element_Script');
HTML_QuickForm2_Factory::registerElement('html', 'Am_Form_Element_Html');
HTML_QuickForm2_Factory::registerElement('csrf', 'Am_Form_Element_Csrf');
HTML_QuickForm2_Factory::registerElement('options_editor', 'Am_Form_Element_OptionsEditor');
HTML_QuickForm2_Factory::registerElement('htmleditor', 'Am_Form_Element_HtmlEditor');
HTML_QuickForm2_Factory::registerElement('magicselect', 'Am_Form_Element_MagicSelect');
HTML_QuickForm2_Factory::registerElement('sortablemagicselect', 'Am_Form_Element_SortableMagicSelect');
HTML_QuickForm2_Factory::registerElement('checkboxedgroup', 'Am_Form_Element_CheckboxedGroup');
HTML_QuickForm2_Factory::registerElement('advfieldset', 'Am_Form_Container_AdvFieldset');
HTML_QuickForm2_Factory::registerElement('multi_select', 'Am_Form_Element_MultiSelect');
HTML_QuickForm2_Factory::registerElement('category', 'Am_Form_Element_Category');
HTML_QuickForm2_Factory::registerRule('callback2', 'Am_Rule_Callback2');
HTML_QuickForm2_Factory::registerRule('remote', 'HTML_QuickForm2_Rule_Remote');
Example #6
0
            } while ($el = $el->getContainer());
            $url = 'http://v4.amember.com/docs/' . $url;
            return $url;
        }
    }
}
class Am_Form_Renderer_User extends Am_Form_Renderer
{
}
class Am_Form_Renderer_Admin extends Am_Form_Renderer
{
}
HTML_QuickForm2_Factory::registerElement('period', 'Am_Form_Element_Period');
HTML_QuickForm2_Factory::registerElement('date', 'Am_Form_Element_Date');
HTML_QuickForm2_Factory::registerElement('integer', 'Am_Form_Element_Integer');
HTML_QuickForm2_Factory::registerElement('advcheckbox', 'Am_Form_Element_AdvCheckbox');
HTML_QuickForm2_Factory::registerElement('advradio', 'Am_Form_Element_AdvRadio');
HTML_QuickForm2_Factory::registerElement('email_checkbox', 'Am_Form_Element_EmailCheckbox');
HTML_QuickForm2_Factory::registerElement('email_select', 'Am_Form_Element_EmailSelect');
HTML_QuickForm2_Factory::registerElement('email_link', 'Am_Form_Element_EmailLink');
HTML_QuickForm2_Factory::registerElement('email_with_days', 'Am_Form_Element_EmailWithDays');
HTML_QuickForm2_Factory::registerElement('upload', 'Am_Form_Element_Upload');
HTML_QuickForm2_Factory::registerElement('script', 'Am_Form_Element_Script');
HTML_QuickForm2_Factory::registerElement('html', 'Am_Form_Element_Html');
HTML_QuickForm2_Factory::registerElement('csrf', 'Am_Form_Element_Csrf');
HTML_QuickForm2_Factory::registerElement('options_editor', 'Am_Form_Element_OptionsEditor');
HTML_QuickForm2_Factory::registerElement('htmleditor', 'Am_Form_Element_HtmlEditor');
HTML_QuickForm2_Factory::registerElement('magicselect', 'Am_Form_Element_MagicSelect');
HTML_QuickForm2_Factory::registerElement('checkboxedgroup', 'Am_Form_Element_CheckboxedGroup');
HTML_QuickForm2_Factory::registerElement('advfieldset', 'Am_Form_Container_AdvFieldset');
HTML_QuickForm2_Factory::registerRule('callback2', 'Am_Rule_Callback2');
Example #7
0
<?php

require_once 'HTML/QuickForm2/Element/Input.php';
if (!class_exists('HTML_QuickForm2_Element_InputNumber')) {
    class HTML_QuickForm2_Element_InputNumber extends HTML_QuickForm2_Element_Input
    {
        protected $attributes = array('type' => 'number');
    }
    HTML_QuickForm2_Factory::registerElement('number', 'HTML_QuickForm2_Element_InputNumber');
}
Example #8
0
<?php

require_once 'HTML/QuickForm2/Element/Input.php';
if (!class_exists('HTML_QuickForm2_Element_InputEmail')) {
    class HTML_QuickForm2_Element_InputEmail extends HTML_QuickForm2_Element_Input
    {
        protected $attributes = array('type' => 'email');
    }
    HTML_QuickForm2_Factory::registerElement('email', 'HTML_QuickForm2_Element_InputEmail');
}
Example #9
0
<?php

require_once 'HTML/QuickForm2/Element/Input.php';
if (!class_exists('HTML_QuickForm2_Element_InputUrl')) {
    class HTML_QuickForm2_Element_InputUrl extends HTML_QuickForm2_Element_Input
    {
        protected $attributes = array('type' => 'url');
    }
    HTML_QuickForm2_Factory::registerElement('url', 'HTML_QuickForm2_Element_InputUrl');
}