Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class form_field_base {
- // Lots of code
- }
- class form_field_text extends form_field_base {
- // Lots of code
- }
- class form_field_email extends form_field_text {
- // Extending the text object to update validation, and set input type="email"
- }
- class form_field_file extends form_field_base {
- // Lots of code, for example uploading files
- }
- class form_field_base_common {
- // Lots of code
- }
- class form_field_base extends form_field_base_common {
- // By default is empty
- }
- class form_field_text_common extends form_field_base {
- // Lots of code
- }
- class form_field_text extends form_field_text_common {
- // ...
- }
- class form_field_email_common extends form_field_text {
- // Extending the text object to update validation, and set input type="email"
- }
- class form_field_email extends form_field_email_common {
- // ...
- }
- class form_field_file_common extends form_field_base {
- // Lots of code, for example uploading files
- }
- class form_field_file extends form_field_file_common {
- // ...
- }
- A <- B <- C
- A->a()
- B->a(), B->b()
- C->a(), C->b(), C->c()
- A1 <- B <- C
- A1->a(), A1->a1(),
- B->a(), B->a1(), B->b()
- C->a(), C->a1(), C->b(), C->c()
- A1 decorates A
- B1 decorates B
- C1 decorates C
- A1 <- B1 <- C1
- A1->a1()
- B1->a1()
- C1->a1()
- A1 hosts a reference of A
- B1 hosts a reference of B
- C1 hosts a reference of C
- A1->a() ----> $this->myA->a();
- B1->a() ----> $this->myB->a();
- B1->b() ----> $this->myB->b();
- A1->a1() ----> $this->a1();
- A1 instead of A
- B1 instead of B
- C1 instead of C
- abstract class FormComponent {
- public __construct(FormField $field) {
- $this->_field = $field;
- }
- public html() {
- // Here you can choose any way to integrate the field's input HTML into
- // the component's HTML. You can wrap it in a label, for example.
- return $self->_get_html() . $self->_field->html_input();
- }
- }
- $field = new form_field_email($arguments); // Whatever arguments it takes
- // Here the FormComponent_Email class inherits the FormComponent class
- $component = new FormComponent_Email($field);
- $component->set_hint('Some hint'); // Set your help text here
- $component->set_label('Enter your email');
- // You can even add an error container if you wish
- if ($some_email_error) {
- $component->set_error('Your email has an error!');
- }
- $component_html = $component->html();
Add Comment
Please, Sign In to add comment