Skip to content

Ranking

Pascal Boucher edited this page Oct 7, 2019 · 7 revisions

Introduction

The ranking service is a powerful set of features to help you move nodes around in your form. It preserves the order in which you want your inputs or html elements to appear in your forms.

List of available methods

add - after - ahead - before - down - inRanking - last - move - rank - remove - reverse - shuffle - sortByRank - toggle - toIndex - toRank - up

add

Add a node in the rankings.
Return the rank of the new node.

@return int

$form->ranking->add($node);

after

Move the node after another node in the ranking.

@return int

$form->ranking->move($node)->after($afterNode);

ahead

Move the node first in the ranking.

@return int

$form->ranking->move($node)->ahead();

before

Move the node before another node in the ranking.

@return int

$form->ranking->move($node)->before($beforeNode);

down

Move the node one rank down.
Return the new rank of the downgraded node.

@return int

$form->ranking->move($node)->down();

inRanking

Check that the node is in the ranking.

@return bool

$form->ranking->inRanking($node);

last

Move the node last in the ranking.
Return the rank of the last node.

@return int

$form->ranking->move($node)->last();

move

Set the node id that is to reorder.
This method has to be called before using those that defines the action to be taken.

@return self

$form->ranking->move($node);

rank

Return the rank of the node in the ranking.

@return int

$form->ranking->rank($node);

remove

Remove a node in the ranking.

@return bool

$form->ranking->remove($node);

reverse

Reverse the ranks in the ranking.

@return void

$form->ranking->reverse();

shuffle

Shuffle the ranks in the ranking.

@return void

$form->ranking->shuffle();

sortByRank

Order the list according to the nodes position in the ranking.

@return Collection

$form->ranking->sortByRank($nodes);

toggle

Toggle two nodes in the ranking.
Return the new rank of the first node.

@return int

$form->ranking->toggle($firstNode, $secondNode);

toIndex

Move the node to a specific index.
Return the new index of the node.

@return int

$form->ranking->move($node)->toIndex(1);

toRank

Move the node to a specific rank.
Return the new rank of the node.

@return int

$form->ranking->move($node)->toRank(1);

up

Move the node one rank up.
Return the rank of the upgraded node.

@return int

$form->ranking->move($node)->up();
Clone this wiki locally