-
When building multiple elements to return, is it possible to build them as sibling elements and return them instead of wrapping them in a div? Here is how I'm doing it so far. Any way to re-write this without the parent div tag wrapping them? public function yesNoRadio($name = null, $model = null)
{
return Div::create()->addChildren(
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'))
)->addChildren(
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')->class('form-check-label'))
);
} |
Beta Was this translation helpful? Give feedback.
Answered by
azamtav
Apr 29, 2024
Replies: 1 comment
-
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')->class('form-check-label'));
return new HtmlString($yes->render() . $no->render());
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
azamtav
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think I figured it out. Instead of wrapping in a div, I can do: