在Codeigniter中提交表单后无法保留下拉值

时间:2019-12-10 09:22:27

标签: php codeigniter codeigniter-3 codeigniter-2

我在codeigniter中工作,并使用下拉列表在select2 jquery下拉列表中填充值, 但问题是表单提交后我无法保留所选的值,使用det_value后它显示的是id而不是文本。 这是我的代码:

$name = array('id'=>'name','name'=>'name','class'=>' form-control');
echo form_dropdown($tutor_name,set_value('name'));

1 个答案:

答案 0 :(得分:0)

请将public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); } 更改为'name'=>'name'

请参考此链接,并根据给定的格式更改代码:

https://codeigniter.com/user_guide/helpers/form_helper.html