Hello everyone!
I would like to insert a custom text before a field. The text should be formatted in html and precede the field label.
I think the solution is to use $html in the hook file's tablename_dv () function but I have no idea how to use it. For example, I would like to display the image mysite / image.jpg before the field label and a paragraph below the image.
Could anyone please tell me how to use the $html parameter?
THANKS!
Fabiano
insert html elements before a field
- D Oliveira
- AppGini Super Hero
- Posts: 348
- Joined: 2018-03-04 09:30
- Location: David
Re: insert html elements before a field
I might be wrong because I never used html in that function but your can try echo '<p> html code</p>'; or close and re-open the php syntax like this:fgazza wrote: ↑2020-06-06 20:02Hello everyone!
I would like to insert a custom text before a field. The text should be formatted in html and precede the field label.
I think the solution is to use $html in the hook file's tablename_dv () function but I have no idea how to use it. For example, I would like to display the image mysite / image.jpg before the field label and a paragraph below the image.
Could anyone please tell me how to use the $html parameter?
THANKS!
Fabiano
Code: Select all
?>
<p>hmtl code</p>
<?php
hope it helps, cheers!
Re: insert html elements before a field
Hi,
appending custom html to the bottom of DV or prepending html to the top is not hard by just modifying the given $html variable. But here, the challenge is to place the custom html above the field.
If this is a normal field (and not a lazy loaded lookup) you can do it this way:
file: hooks/TABLENAME.php
Result
Inserted above field named "resource_type".
Regards,
Jan
appending custom html to the bottom of DV or prepending html to the top is not hard by just modifying the given $html variable. But here, the challenge is to place the custom html above the field.
If this is a normal field (and not a lazy loaded lookup) you can do it this way:
file: hooks/TABLENAME.php
Code: Select all
function TABLENAME_dv($selectedID, $memberInfo, &$html, &$args)
{
$fieldname = "resource_type"; // TODO: change $fieldname
$html .= '<p id="my_custom_paragraph" class="well">my <i>custom paragraph</i> with <b>bold</b> text</p>';
$html .= '<script>$j("#my_custom_paragraph").prependTo($j("#' . $fieldname . '").closest(".form-group"))</script>';
// ...
}
Result
Inserted above field named "resource_type".
Regards,
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: insert html elements before a field
Many thanks!
with your suggestion I prepared the form correctly (i set my code into div tag and not into p tag because i have several paagraph and an image) but unfortunately if I view the form itself with the "print" option (print view), my custom html code is displayed below the form fields.
I would be grateful for your help.
with your suggestion I prepared the form correctly (i set my code into div tag and not into p tag because i have several paagraph and an image) but unfortunately if I view the form itself with the "print" option (print view), my custom html code is displayed below the form fields.
I would be grateful for your help.
- D Oliveira
- AppGini Super Hero
- Posts: 348
- Joined: 2018-03-04 09:30
- Location: David
Re: insert html elements before a field
could try modifying the tablename_DV.html template in templates folder and see how it goesfgazza wrote: ↑2020-06-12 13:44Many thanks!
with your suggestion I prepared the form correctly (i set my code into div tag and not into p tag because i have several paagraph and an image) but unfortunately if I view the form itself with the "print" option (print view), my custom html code is displayed below the form fields.
I would be grateful for your help.
Re: insert html elements before a field
Thank you but as I renew many times my app generating new files by appgini tool i prefer a solution that affect only the hook file.