Skip to content

Is it possible to build two sibling elements without wrapping in div and return from a function? #227

Answered by azamtav
azamtav asked this question in Q&A
Discussion options

You must be logged in to vote

I think I figured it out. Instead of wrapping in a div, I can do:

public function yesNoRadio($name = null, $model = null)
{
    $yes = Div::create()->class('form-check form-check-inline')
        ->addChildren($this->radio($name)->class('form-check-input')->id($name.'_yes')->value(1)->checked(old($name) === '1' || $model[$name] === 1))
        ->addChildren($this->label('Yes')->for($name.'_yes')->class('form-check-label'));

    $no = Div::create()->class('form-check form-check-inline')
        ->addChildren($this->radio($name)->class('form-check-input')->id($name.'_no')->value(0)->checked(old($name) === '0' || $model[$name] === 0))
        ->addChildren($this->label('No')->for($name.'_no')…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by azamtav
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant