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

add content at end of control #383

Open
tgoeminne opened this issue Apr 20, 2023 · 4 comments
Open

add content at end of control #383

tgoeminne opened this issue Apr 20, 2023 · 4 comments

Comments

@tgoeminne
Copy link

Hi,

I want to add content at the end of a form control. eg another hidden input. I can use the help option but then it will be inside the small container. Is there another option I am overlooking?

@tgoeminne
Copy link
Author

hi any reply on this I am trying to figure out how this plugin works but have hard time fixing it..

$templates = [
'inputGroupContainer' =>'<div{{attrs}}>{{prepend}}{{content}}{{append}}{{extra}}',
'extra' => '{{content}}',
];

I am using this but with no luck all that happen is the extra

echo $this->Form->control('name', ['label' => 'Name', 'extra' => 'how are you doing?' , 'templates' => $templates]);

expected result:

how are you doing?

actual

Can tell me what I am doing wrong here?

greets,
Thomas

@tgoeminne
Copy link
Author

Also it would appear that the error messages are no longer shown on text inputs? Is this broken ?

@ndm2
Copy link
Collaborator

ndm2 commented May 8, 2023

You cannot add custom templates like that, the underlying string template functionality provided by CakePHP doesn't support that. What you can do however is adding template variables:

$this->Form->setTemplates([
    'inputContainer' =>
        '<div{{containerAttrs}} ' .
            'class="{{containerClass}}form-group {{type}}{{required}}">{{content}}{{help}}{{extra}}</div>',

    'inputContainerError' =>
        '<div{{containerAttrs}} ' .
            'class="{{containerClass}}form-group {{formGroupPosition}}{{type}}{{required}} is-invalid">' .
                '{{content}}{{error}}{{help}}{{extra}}</div>',
]);

// ...

echo $this->Form->control('name', [
    'label' => 'Name',
    'templateVars' => [
        'extra' => 'how are you doing?'
    ],
]);

@tgoeminne
Copy link
Author

thanks, will take a look at that

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

2 participants