code where to place it

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
pasbonte
Veteran Member
Posts: 178
Joined: 2013-02-06 09:49

code where to place it

Post by pasbonte » 2024-10-05 06:46

Hello
I have this code for example I think it can work but I don't know where to put it, where to place it..

Code: Select all

<?php 
function GES_SUIVI_INDIVIDUEL($selectedID, $memberInfo, 
&$html, &$args) { 
 // Ajouter un div contenant un séparateur avant certains champs 
 $html = str_replace('<div class="form-group" id="NOM_ELEVE">', '<div style="border-top: 1px solid #ccc; margin-top: 10px;"></div><div class="form-group" id="NOM_ELEVE">', $html); 
} 
?>
or for ex

Code: Select all

function validate_my_form($options, $memberInfo, &$args)
{
    if(empty($args['my_field']))
    {
        $args['__form_valid'] = false;
        $args['__form_msg'] = 'Le champ "My Field" est obligatoire.';
    }
}



User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1891
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: code where to place it

Post by jsetzer » 2024-10-05 07:15

Analysis

(1)
First function looks like a replacement for TABLENAME_dv($selectedID, $memberInfo, &$html, &$args)-function in hooks/TABLENAME.php.

if (!) there was a <div class="form-group">...</div>, having a certain id='NOM_ELEVE' in a standard Detail View, this code would add a grey top border and top-margin.

But standard AppGini generated form-groups do not have any id attribute, as far as I know. So, this code will do just nothing unless you managed to add an id="NOM_ELEVE"-attribute to a detail view form-group.

(2)
Second function looks like it's meant to be a form validation function for form data.

But in standard AppGini, this will never get executed, unless you call it by yourself and evaluate $args by yourself.

---

Honestly speaking, those two functions look like AI-generated code fragments, missing knowledge about AppGini generated PHP and Javascript code. Sorry, if I'm wrong. I don't want to blame the author.

---

Possible solutions
You could tell us what you want and we can give you working code, for example:

(1) Add Border and margin to a form-group*
* Replace TABLENAME and COLUMNNAME accordingly

Code: Select all

// file: hooks/TABLENAME-dv.php
jQuery('.form-group.TABLENAME-COLUMNNAME').addClass("border-top");

Code: Select all

<!-- file: hooks/header-extras.php -->
<style>
.border-top {
    border-top: 1px solid #ccc;
    margin-top: 10px;
}
</style>
(2) Form Validation

Make use of TABLENAME_before_insert()-function and TABLENAME_before_update()-function in hooks/TABLENAME.php.

---
Please don't get me wrong, I really don't want to blame anyone. For me, those code fragments look like they are pointing you into a wrong direction and would bring more effort than needed. AppGini already brings validation features when using the _before_ hooks.
Kind regards,
<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 readability

AppGini 24.14 Revision 1665 + all AppGini Helper tools

pasbonte
Veteran Member
Posts: 178
Joined: 2013-02-06 09:49

Re: code where to place it

Post by pasbonte » 2024-10-05 07:34

No problem
the fisrt yes IA but second no,

I work on these codes but I'm not a professional, and the logic of APPGONI escapes me a little sometimes.

AI helps me but I'm trying to understand too,

I'm moving forward little by little, but having a job I don't have too much time too

That's why I start with simple codes that I analyze and try, my way of doing things is empirical... I know

I will try your proposal and work on it, thank you

merci

ppfoong
Veteran Member
Posts: 52
Joined: 2021-07-13 16:46

Re: code where to place it

Post by ppfoong » 2024-10-05 09:24

For the 2nd function, you don't need to code at all.

You just need to check the field as "Required" in Appgini and generate the codes. Appgini will make sure it cannot be empty before save.

Post Reply