Symfony 3改变标签主题

时间:2016-04-28 17:51:35

标签: twitter-bootstrap symfony

我正在使用bootstrap 3表单主题。

import UIKit

class ViewController: UIViewController {
    var buttonView:UIView!
    var toggleButton:UIButton!
    var isVisible = false

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        let buttonTitles = ["1", "2", "3"]
        let size:CGFloat = 100.0

        let viewSize = CGFloat(buttonTitles.count) * size
        buttonView = UIView(frame: CGRectMake(40, 40, viewSize, viewSize))

        setAnchorPoint(CGPointMake(0.5, 0), forView: buttonView)
        buttonView.layer.anchorPoint = CGPointMake(0.5, 0.0)
        view.addSubview(buttonView)

        for (index, title) in buttonTitles.enumerate() {
            let button = UIButton(type: .Custom) as UIButton
            button.frame = CGRectMake(0, size * CGFloat(index), size, size)
            button.setTitle(title, forState: .Normal)
            button.backgroundColor = UIColor.redColor()
            buttonView.addSubview(button)
        }

        toggleButton = UIButton(type: .Custom) as UIButton
        toggleButton.frame = CGRectMake(200, 100, 80, 50)
        toggleButton.setTitle("Toggle", forState: .Normal)
        toggleButton.backgroundColor = UIColor.purpleColor()
        toggleButton.addTarget(self, action: #selector(ViewController.animate), forControlEvents: .TouchUpInside)
        view.addSubview(toggleButton)
    }

    func setAnchorPoint(anchorPoint: CGPoint, forView view: UIView) {
        var newPoint = CGPointMake(view.bounds.size.width * anchorPoint.x, view.bounds.size.height * anchorPoint.y)
        var oldPoint = CGPointMake(view.bounds.size.width * view.layer.anchorPoint.x, view.bounds.size.height * view.layer.anchorPoint.y)

        newPoint = CGPointApplyAffineTransform(newPoint, view.transform)
        oldPoint = CGPointApplyAffineTransform(oldPoint, view.transform)

        var position = view.layer.position
        position.x -= oldPoint.x
        position.x += newPoint.x

        position.y -= oldPoint.y
        position.y += newPoint.y

        view.layer.position = position
        view.layer.anchorPoint = anchorPoint
    }

    func animate() {

        if (isVisible) { // collapse it
            isVisible = false

            UIView.animateWithDuration(0.5, animations: { 
                self.buttonView.transform = CGAffineTransformMakeScale(0.2, 0.2)
            })
        }

        else { // expand it
            isVisible = true

            UIView.animateWithDuration(0.5, animations: {
                self.buttonView.transform = CGAffineTransformMakeScale(1.0, 1.0)
            })
        }
    }   
}

我可以添加到{% use 'bootstrap_3_layout.html.twig' with form_widget_simple as form_widget_simple_base, form_label as form_label_base %} {% form_theme form _self %} {% block text_label %} <span class="input-group-addon">{{ ???? }}</span> {% endblock %} {% block text_row %} <div class="input-group"> {{ block('text_label') }} {{ block('form_widget_simple_base') }} </div> {% endblock %} {% block body %} <div class="container"> <div class="row"> <div class="col-xs-8"> <h4>Product form</h4> {{ form_start(form) }} {{ form_row(form.name) }} {{ form_end(form) }} </div> </div> </div> {% endblock %} {{block(&#39; form_label_base&#39;),但它会在标记中呈现每个内容。我希望文本格式的简单标签没有任何HTML标签。有可能吗?

1 个答案:

答案 0 :(得分:1)

您只需将label var放在此处:

{% block text_label %}
    <span class="input-group-addon">{{ label }}</span>
{% endblock %}