2017 © Pedro PelΓ‘ez
 

library form

image

mindy/form

  • Tuesday, November 1, 2016
  • by max107
  • Repository
  • 1 Watchers
  • 0 Stars
  • 422 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 34 Versions
  • 0 % Grown

The README.md

Mindy form component

Build Status, (*1)

Issues, (*2)

Widget

ИспользованиС Π²ΠΈΠ΄ΠΆΠ΅Ρ‚ΠΎΠ² Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ ΠΊΠΎΠ³Π΄Π° ΠΊ полю Ρ„ΠΎΡ€ΠΌΡ‹ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ Π΄ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ Π½Π΅ΠΊΡƒΡŽ Π»ΠΎΠ³ΠΈΠΊΡƒ. К ΠΏΡ€ΠΈΠΌΠ΅Ρ€Ρƒ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎΠ³ΠΎ поля с тСкстом Π»ΠΈΡ†Π΅Π½Π·ΠΈΠΈ, ΠΎΡ‚ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅ Ρ€Π΅ΠΉΡ‚ΠΈΠ½Π³Π° с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ стороннСго ΠΏΠ»Π°Π³ΠΈΠ½Π°, ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ ΠΊΠ°Ρ€Ρ‚Ρ‹ ΠΈ Ρ‚Π°ΠΊ Π΄Π°Π»Π΅Π΅., (*3)

ΠŸΡ€ΠΈΠΌΠ΅Ρ€ Π²ΠΈΠ΄ΠΆΠ΅Ρ‚Π°:, (*4)

<?php

namespace Mindy\Form\Widget;

use Mindy\Form\Widget;
use Mindy\Helper\JavaScript;
use Mindy\Helper\JavaScriptExpression;

class RatingWidget extends Widget
{
    public $options = [];

    /**
     * @return string
     */
    public function render()
    {
        $field = $this->getField();
        $jsOptions = JavaScript::encode(array_merge([
            'starType' => 'i',
            'numberMax' => 5,
            'score' => $field->getValue(),
            'click' => new JavaScriptExpression('function(score, evt) {
                $("#' . $field->getHtmlId() . '").val(score);
            }')
        ], $this->options));
        $js = "<div id='{$field->getHtmlId()}_rating' class='rating-input'></div><script type='text/javascript'>$('#{$field->getHtmlId()}_rating').raty({$jsOptions});</script>";
        return $field->renderInput() . $js;
    }
}

ИспользованиС:, (*5)

<?php

class MyForm extends Form
{
    public function getFields()
    {
        return [
            'rating' => [
                'class' => CharField::class,
                'widget' => new RatingWidget
            ]
        ];
    }
}

The Versions

01/11 2016