We want to the ability to dynamically add more content to our clips so I added the properties $appendToClip and $prependToClip to CClipWidget
Adding $appendToClip and $prependToClip to CClipWidget.
Merge remote-tracking branch 'yiisoft/master'
What's the use case for it?
Example, have the controller or extension add the clip and then be able to append to it in a view file.
I meant real use example.
@MrTin will close this as you gave no feedback for 5 month..
Also looking for this feature. Re-open or should I create a new PR?
Here is a real use case:
ModelA belongs to ModelB, ModelC and ModelD.
While rendering the update form for ModelA, "Add ModelX" buttons are included, which shows bootstrap modals containing create forms for the related models.
Since forms can't be included within each other, the markup for the modals needs to be included outside of the forms.
To support proper recursive rendering of nested relations and their respective modal forms, it makes sense to have each form append the markups for the modals to a clip named 'modals'.
The topmost parent form can then simply print out this clip outside of the original form.
Can you show some code for it using the addition in the pull request?
Clip contents to append
My proposed use-case has a flaw: When rendering clips recursively, several beginClip will reference the same id before the first endClip, causing only some clips to actually be appended to (the ones in the first level of recursion).
In other words: Clips do not support recursion, even with this pr (not surprising).
The ability to store markup for modals in some sort of ClipCollection to be rendered after a form, or at the end of body, is still desired. Currently had to resort to use clips with names like "modal:the-form-id" and then loop through the clips after the form and print out all beginning with "modal:".
@motin do you have better solution? Is this pull request necessary considering what you've found out?
@samdark: A more general purpose solution for the use-case I mentioned above would be to have a similar method to CClientScript's registerScript, but for markup, so that chunks of markup can be inserted into the end of body while rendering the page. This makes sense for modals, dialogs etc that require markup.