Download the PHP package flsouto/htbutton without Composer

On this page you can find all versions of the php package flsouto/htbutton. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package htbutton

HtButton

Overview

This class allows you to easily create html form buttons in an object oriented way and comes with the following features:

Notice: this class extends an abstract class called HtField. The inherited functionality will not be covered here. So, if you find difficulty in understanding something, please refer to this documentation.

Installation

Use composer:

Usage

The below code simply creates and renders a button named "action". Notice that by default the button's label is its own name with the first letter in upper case:

The above code will produce the following output:

Specifing a label

The second parameter to the constructor accepts a label string:

The output will be:

Using the label setter

If you desire to set label after construction, use the label setter:

Outputs:

Inline/Block Layout

By default the button is rendered in block mode, meaning that it will always appear in a new line. In order to change it so that it is rendered in the same line, you have to call the inline method:

The output will be:

As you can see, it has simply added some css properties to the button's "style" attribute.

Calling the same method with a false argument will return to the block layout:

Output:

Adding custom CSS

Pass an array to the àttrs method with a style key like in the example below:

Outputs:

Changing default value

The value that gets sent on a form submission event is by default a random string which is the same as the button's id. So, if you want to change that, you have to change the id attribute:

Checking if button has been pressed

If you nested your button inside a form, chances are you will need at some point to check if that button has been pressed so you can process the requested action:

Outputs:

Handling multiple buttons

Sometimes you may want to have more than one action available in a form. In this case you will probably need to have muliple buttons and be able to tell which one has been clicked. The following snippet shows you how to do just that:

The output will be:

Handling buttons with same name

I wouldn't recommend giving the same name to different buttons on the same form, but, since I've seen this pattern been used by many developers I decided to include an example of how one could handle that problem through this API. You basically have to give a different id/value to each button and check which one has been sent in a switch block:

The output will be:


All versions of htbutton with dependencies

PHP Build Version
Package Version
Requires flsouto/htfield Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package flsouto/htbutton contains the following files

Loading the files please wait ....