如何仅为默认语言设置必填字段?

时间:2017-01-06 08:30:29

标签: laravel laravel-5 laravel-5.2

我有这个输入,我输入语言一些文本。现在我想设置必填字段,但仅限于其语言代码[de]。当我这样做时,我得到所有语言的必填字段。任何建议如何解决这个问题?

public class SelectStateDescribingLinearLayout extends LinearLayout {

    public SelectStateDescribing(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public CharSequence getContentDescription() {
        CharSequence contentDescription = super.getContentDescription();
        return isSelected() ? appendSelectedTo(contentDescription) : contentDescription;
    }

    private String appendSelectedTo(CharSequence contentDescription) {
        return getResources().getString(R.string.viewgroup_selected, contentDescription);
    }
}

编辑:

我找到了这个解决方案,它对我有用。 https://laracasts.com/discuss/channels/general-discussion/laravel-5-dynamic-form-validation?page=1

1 个答案:

答案 0 :(得分:0)

如果您有以下网址,可以通过reuquest检查语言:www.xxxxx.com/de或者您可以使用lang值传递隐藏输入,而不是:

class StreamingEnvironment(sparkConf: SparkConf, kafkaConf: KafkaConf) {
    val sparkContext = spark.SparkContext.getOrCreate(sparkConf)
    lazy val streamingContext = new StreamingContext(sparkContext, Seconds(30))

    mStreamingContext.checkpoint(/*directory checkpoint*/)
    mStreamingContext.remember(Minutes(1))

    def stream() = KafkaUtils.createDirectStream[String, String, StringDecoder, StringDecoder](streamingContext, myKafkaConf.mBrokers, myKafkaConf.mTopics)
    def stop() = sparkContext.stop()
}

object StreamingEnvironment {
    def apply(kafkaConf: KafkaConf) = {
    val sparkConf = new SparkConf

    new StreamingEnvironment(sparkConf, kafkaConf)
    }
}

请求:

<input type="hidden" name="lang" value="de">

或隐藏输入

if(request()->segment(2) == 'de') {
    return [
        'article_title[de]'             => 'required:articles',
        'slug'                          => 'required|unique:articles',
        'article_intro[de]'             => 'required:articles',
        'article_content[de]'           => 'required:articles',
        'article_category[de]'          => 'required|exists:categories,id',
    ]
} else {
    return [];
}