PHP code example of unclecheese / betterbuttons

1. Go to this page and download the library: Download unclecheese/betterbuttons library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

unclecheese / betterbuttons example snippets


    public function getBetterButtonsActions() {
        $fields = parent::getBetterButtonsActions();
        if($this->IsApproved) {
            $fields->push(BetterButtonCustomAction::create('deny', 'Deny'));
        }
        else {
            $fields->push(BetterButtonCustomAction::create('approve', 'Approve'));
        }
        return $fields;
    }

    public function approve() {
        $this->IsApproved = true;
        $this->write();
    }

    public function deny() {
        $this->IsApproved = false;
        $this->write();
    }

    private static $better_buttons_actions = array (
        'approve',
        'deny'
    );

  $fields->push(
    BetterButtonCustomAction::create('deny', 'Deny')
      ->setRedirectType(BetterButtonCustomAction::REFRESH)
  );

BetterButtonCustomAction::REFRESH
BetterButtonCustomAction::GOBACK

    public function deny() {
        $this->IsApproved = false;
        $this->write();

        return 'Denied for publication';
    }

    $fields->push(
        new BetterButtonLink(
          'View on Meetup.com',
           $this->MeetUpLink
        )
    );

	public function getBetterButtonsActions() {
		$f = parent::getBetterButtonsActions();
		$f->push(BetterButtonNestedForm::create('sendmessage','Send this customer a message', FieldList::create(
			TextareaField::create('Content')
		)));

		return $f;
	}

    public function sendmessage ($data, $form) {
    	$message = Message::create(array (
    		'OrderID' => $this->ID,
    		'Content' => $data['Content']
    	));

    	$message->write();
    	$form->sessionMessage('Message sent','good');
    }