Skip to content

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

@emeraldjava

Description

@emeraldjava

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions