Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp_form_htmltag_default - add an extra attribute to the element to support this customisation #7

Open
emeraldjava opened this issue Jan 13, 2014 · 0 comments

Comments

@emeraldjava
Copy link

Hey,

I've been looking at this code trying to understand how i can tell the $element type within my filter method implementation. Instead of applying a callback here I think it would be better to have an optional method on each element which would be defined as part of the form definition. The default of course would be 'div'.

class WP_Form_Decorator_HtmlTag extends WP_Form_Decorator {
        // TODO: some sort of callback for context-aware attributes
        public function render( WP_Form_Component $element ) {
                $args = wp_parse_args(
                        $this->args,
                        array(
                                //  apply_filters('wp_form_htmltag_default', 'div'),
                                'tag' =>$element->get_htmltag_default(),
                                'attributes' => array(),
                        )
                );
                return $this->open_tag($args['tag'], $args['attributes']) . $this->component_view->render($element) . $this->close_tag($args['tag']);
        }
```ruby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant