Modifying existing Plugin produces no result

I am modifying an existing plugin and simply added an additional input line in the form as to acquire one additional piece of data from the user.

The existing plug in gathers: Title, Description and Sale Price. I want the poster to be able to add the "Regular Price"

I duplicated the code for the "Sale Price" in /views/default/forms/YYY/save.php and tailored it for "Regular Price" with the following modified code:

$regular_label = elgg_echo('Regular Price')."*";
$regular_input = $currency.elgg_view('input/text', array(
'name' => 'regular',
'id' => 'YYY_regular',
'value' => $vars['regular']


I then similarly modifed /actions/YYY/save.php to add 'regular' to ElggObject with the following code:

$YYY = new ElggObject();
$YYY->subtype = 'YYY';
$new_post = TRUE;

$values = array(
'title' => '',
'description' => '', 'sale' =>",

'regular' => '',
'container_guid' => (int)get_input('container_guid'),

Finally I modifed /views/defaul/object/YYY.php and added the code:

$body .= "" . elgg_echo('Regular Price') . " {$currency}{$YYY->regular}****" ;
$body .= "";

On the output, I am seeing the entered data as normal for "Title", "Description", and "Sale Price", however for "Regular Price" the output is "Regualr Price $***" not seeing the entered data amount as I do for "Sale Price".

What am I missing? It doesn't seem like Regular Price is getting added to the database.

Thanks in Advance!

  • So far I found 1 error in the action file. The line

    $required = array('title', 'description', ''sale', 'regular');

    should be

    $required = array('title', 'description', 'sale', 'regular');

    I don't know if this is the reason the regular price is not displayed. Actually, I wonder that the code even worked with this error. Can you check if it works with the correct line?

  • It still doesn't work even with the corrected line. Sorry I didn't catch that earlier, as I played around with a code version where I changed all the ' to " and then changed it back but didn't change the one back after it didnt work. my bad... 

  • The problem can be within the code of the input form, the action file that processes the input or in the code of the output view. Let's assume for the moment that the action file is not the problem as it looks at least to me okay (and it processes the other input values okay). Then the problem at the moment is that either the entered data does not even reach the action file to be saved or that the value is correctly saved but not displayed.

    Try the following:

    In the action file are the lines:

    // load from POST and do sanity and access checking
    foreach ($values as $name => $default) {
        $value = get_input($name, $default);

    Below this line add the following bold lines to get this code:

    // load from POST and do sanity and access checking
    foreach ($values as $name => $default) {
        $value = get_input($name, $default);

        if ($name == 'regular') {
            $value = 'A Test value';

        if (in_array($name, $required) && empty($value)) {
            $error = elgg_echo("sbuys:error:missing:$name");

    This should save whatever you enter as 'A Test value' to the object. Now you don't need to bother with the input form for the moment as regardless what you will enter there for regular will be ignored. What do you see on the output now? Is 'A Test value' displayed? If not, the problem is in the output view and you would need to find out what's wrong there. If the test value does show up, the problem is rather in the input form and you would need to look for the error there.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking