Menu

Prompt on Save

Help
croaker___
2013-01-08
2014-05-18
  • croaker___

    croaker___ - 2013-01-08

    I'd like to create a button which checks a few things and if there's anything wrong, prompt the user and ask
    "Save Anyway?" 

    The checking would be PHP in the mask and the prompt would be a javascript prompt() I guess.

    Anyone got an example of something similar?

    Cheers

     
  • Stephen Penn

    Stephen Penn - 2013-01-08

    well if you want to prompt the user to have to give confirmation then i think you need to use:

    ->requireConfirmation();

    here's the source for the function (maybe make your own custom?)

    public function requireConfirmation($action = 'onclick', $confirmation_text = true)
    {
    $action = strtolower($action);
    if (!$this->actions) {
    trigger_error("you've to call addaction before requireConfirmation", E_USER_ERROR);
    }
    if ($confirmation_text === true) {
    $confirmation_text = 'Are you sure?';
    }
    $this->actions = $confirmation_text;
    return $this;
    }

    use the 'onclick' function to lead to a separate function to do the checks :)

    Hope this helps!

    Steve.

     
  • gerry

    gerry - 2014-05-18

    Here is a sample of code I use:

    $this->build("p4a_button", "save")
            ->setLabel("Save")
            ->addAction("onclick")
            ->requireConfirmation("onclick", "Save Changes? ")
            ->implement("onclick", $this, "save_data");
    
     

Log in to post a comment.