public function testRemoveFieldNamesReorder()
 {
     $v = new fValidation();
     $v->addRequiredFields('foobar', 'foo', 'baz', 'name');
     $v->addOneOrMoreRule('email', 'phone');
     $v->setMessageOrder('email', 'foo', 'baz');
     $this->assertSame(array('email,phone' => 'Please enter a value for at least one', 'foobar' => 'Please enter a value', 'foo' => 'Please enter a value', 'baz' => 'Please enter a value', 'name' => 'Please enter a value'), $v->validate(TRUE, TRUE));
     $this->assertNotSame(array('email,phone' => 'Please enter a value for at least one', 'foo' => 'Please enter a value', 'foobar' => 'Please enter a value', 'baz' => 'Please enter a value', 'name' => 'Please enter a value'), $v->validate(TRUE, TRUE));
 }
Beispiel #2
0
    }
    include 'views/consumables/addedit.php';
}
/**
 * Edit a consumable
 */
if ($action == 'edit') {
    // Get ID
    $id = fRequest::get('id', 'integer');
    try {
        // Get consumable via ID
        $c = new Consumable($id);
        if (fRequest::isPost()) {
            // Try to validate options
            $validator = new fValidation();
            $validator->addOneOrMoreRule('col_c', 'col_y', 'col_m', 'col_k');
            $validator->overrideFieldName(array('col_c' => 'Colour (Cyan)', 'col_y' => 'Colour (Yellow)', 'col_m' => 'Colour (Magenta)', 'col_k' => 'Colour (Black)'));
            $validator->validate();
            // Update consumable object from POST data and save
            $c->populate();
            $c->linkModels();
            $c->linkTags();
            $c->store();
            // Messaging
            fMessaging::create('affected', fURL::get(), $c->getId());
            fMessaging::create('success', fURL::get(), 'The consumable ' . $c->getName() . ' was successfully updated.');
            fURL::redirect(fURL::get());
        }
    } catch (fNotFoundException $e) {
        fMessaging::create('error', fURL::get(), 'The consumable requested, ID ' . $id . ', could not be found.');
        fURL::redirect(fURL::get());