Jump to content

Allow a client to edit a products custom field from productdetails page

Recommended Posts

I'm looking to basically allow editing of a custom field for a product.

I would like to essentially clone how the change password function works but with just one input field and when it saves it updates the custom field and runs a custom function.

I have a function and clientareacustombutton which opens a macaddy.tpl file with form input. It seems like the documentation and examples are scarse and missing vital example.

function from the module

function freeradius_ClientAreaCustomButtonArray() {
    $buttonarray = array(
     "Change MacAddress" => "changemac",
    return $buttonarray;

function freeradius_changemac($vars) {
    return array(
        'templatefile' => 'macaddy',
        'breadcrumb' => array(
            'stepurl.php?action=this&var=that' => 'Change MacAddress',
        'vars' => $params
    $CurrentMacAddress = $params['customfields']['MacAddress'];

    if($_POST['newmac']) {

    $username = $params["username"];
    $password = $params["password"];
    $newmacaddy = $_POST["newmac"];

    shell_exec("/some/path/to/perfect_dark_setup.sh update $username $newmacaddy"); //returns a macaddress as a string like 'c2:eb:e8:31:98:01'

            ->where('relid', '=', $params["serviceid"])
            ->where('fieldid', '=', 1)
                'value' => $newmacaddy,



<form method="post" action="clientarea.php?action=productdetails">
<input type="hidden" name="id" value="{$serviceid}" />
<input type="submit" value="« Back to Service" class="btn" style="float: right;" />

    <div class="tab-pane fade in" id="tabChangeMacAddy">

        <h3>Change MacAddress</h3>

        <form class="form-horizontal" method="post" action="/clientarea.php?action=productdetails" role="form">
            <input type="hidden" name="id" value="{$serviceid}" />
            <input type="hidden" name="a" value="changemac" />
            <div id="newMacAddy" class="form-group has-feedback">
                <label for="inputNewMacAddy" class="col-sm-4 control-label">New MacAddress</label>
                <div class="col-sm-5">
                    <input type="text" class="form-control" id="inputNewMacAddy" name="newmac" autocomplete="off" value="{$newmac}" />
                    <span class="form-control-feedback glyphicon"></span>
                    <br />

            <div class="form-group">
                <div class="col-sm-offset-6 col-sm-6">
                    <input class="btn btn-primary" type="submit" value="Save Changes" />
                    <input class="btn" type="reset" value="Cancel" />


How it looks currently:



After submitting it takes me back to the main product details page and the custom function and update are not executed.

I reviewed both the below pages and all tpl and templates I could find that were not encoded for reference, but was unable to determine if form input is not being passed back



Probably missing something simple here. Any advice or examples would be helpful.  It seems like allowing clients to be able to edit a product's custom field should not be so difficult. Especially since the functionality exists on custom client fields just not implemented on product custom fields 😕

Hoping someone else who has already done this can point me in the right direction.



Edited by whattheserver

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.


Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated